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 729b369 commit 8868d48Copy full SHA for 8868d48
valid-anagram/seona926.js
@@ -0,0 +1,32 @@
1
+/**
2
+ * @param {string} s
3
+ * @param {string} t
4
+ * @return {boolean}
5
+ */
6
+let isAnagram = function (s, t) {
7
+ let cntObj = {};
8
+
9
+ s.split("").forEach((item) => {
10
+ if (cntObj[item]) {
11
+ ++cntObj[item];
12
+ } else {
13
+ cntObj[item] = 1;
14
+ }
15
+ });
16
17
+ for (let item of t) {
18
+ if (cntObj[item] === undefined || cntObj[item] < 1) {
19
+ return false;
20
21
+ --cntObj[item];
22
23
24
25
+ for (let count of Object.values(cntObj)) {
26
+ if (count > 0) {
27
28
29
30
31
+ return true;
32
+};
0 commit comments