Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ae438f7 commit aa54a20Copy full SHA for aa54a20
javascript/242-Valid-Anagram.js
@@ -0,0 +1,34 @@
1
+/**
2
+ * @param {string} s
3
+ * @param {string} t
4
+ * @return {boolean}
5
+ */
6
+var isAnagram = function(s, t) {
7
+ let map = {};
8
+
9
+ if (s.length !== t.length) {
10
+ return false;
11
+ }
12
13
+ for (let i = 0; i < s.length; i++) {
14
+ if (map[s[i]]) {
15
+ map[s[i]]++;
16
+ } else {
17
+ map[s[i]] = 1;
18
19
20
21
+ for (let i = 0; i < t.length; i++) {
22
+ if (map[t[i]]) {
23
+ map[t[i]]--;
24
25
26
27
28
29
+ return true;
30
31
32
33
34
+};
0 commit comments