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 1926e43 commit 8cc2f40Copy full SHA for 8cc2f40
โvalid-anagram/Yu-Won.jsโ
@@ -0,0 +1,24 @@
1
+/**
2
+ * ๋ฌธ์ : https://leetcode.com/problems/valid-anagram/description/
3
+ *
4
+ * ์๊ตฌ์ฌํญ:
5
+ * ๋๊ฐ์ ๋ฌธ์์ด์ด ์ฃผ์ด์ก์ ๋ ๋๊ฐ์ ๋ฌธ์์ด์ด ์ ๋๊ทธ๋จ์ธ์ง ํ๋จํด์ boolean ์ผ๋ก ๋ฆฌํด
6
7
+ * * */
8
+
9
+const validAnagram = (s, t) => {
10
+ if(s.length !== t.length) return false;
11
12
+ let count = {};
13
14
+ for(const sChar of s) {
15
+ count[sChar] = (count[sChar] || 0) + 1;
16
+ }
17
18
+ for(const tChar of t) {
19
+ if(!count[tChar]) return false;
20
+ count[tChar]--;
21
22
23
+ return true;
24
+}
0 commit comments