Skip to content

Commit 9aca042

Browse files
committed
Add solution #242
1 parent e47c80f commit 9aca042

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
219|[Contains Duplicate II](./0219-contains-duplicate-ii.js)|Easy|
4949
226|[Invert Binary Tree](./0226-invert-binary-tree.js)|Easy|
5050
234|[Palindrome Linked List](./0234-palindrome-linked-list.js)|Easy|
51+
242|[Valid Anagram](./0242-valid-anagram.js)|Easy|
5152
263|[Ugly Number](./0263-ugly-number.js)|Easy|
5253
264|[Ugly Number II](./0264-ugly-number-ii.js)|Medium|
5354
268|[Missing Number](./0268-missing-number.js)|Easy|

solutions/0242-valid-anagram.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* 242. Valid Anagram
3+
* https://leetcode.com/problems/valid-anagram/
4+
* Difficulty: Easy
5+
*
6+
* Given two strings s and t, return true if t is an anagram of s, and false otherwise.
7+
*/
8+
9+
/**
10+
* @param {string} s
11+
* @param {string} t
12+
* @return {boolean}
13+
*/
14+
var isAnagram = function(s, t) {
15+
const sort = str => str.split('').sort().join('');
16+
return sort(s) === sort(t);
17+
};

0 commit comments

Comments
 (0)