We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8cd28db commit 6bcbeb0Copy full SHA for 6bcbeb0
leetcode/valid-anagram/index.js
@@ -1,3 +1,34 @@
1
+/**
2
+ * @param {string} s
3
+ * @param {string} t
4
+ * @return {boolean}
5
+ */
6
+var isAnagram = function(s, t) {
7
+ if (s.length !== t.length) {
8
+ return false
9
+ }
10
+
11
+ let sCharCount = {};
12
13
+ for (let i = 0; i < s.length; i++) {
14
+ let sChar = s[i];
15
+ sCharCount[sChar] = sCharCount[sChar] + 1 || 1;
16
17
18
+ for (let i = 0; i < t.length; i++) {
19
+ const tChar = t[i];
20
+ if ( !sCharCount[tChar] ) {
21
22
+ } else {
23
+ sCharCount[tChar]--
24
25
26
27
+ return true;
28
+};
29
30
+// ================================================================================================================================================================
31
32
/**
33
* @param {string} s
34
* @param {string} t
0 commit comments