Skip to content

Commit c6ffd48

Browse files
committed
🟢 Solve problem 242
1 parent 826c27d commit c6ffd48

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

‎swift/242.swift‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution {
2+
func isAnagram(_ s: String, _ t: String) -> Bool {
3+
if s.count != t.count {
4+
return false
5+
}
6+
7+
var countS: [Character: Int] = [:]
8+
var countT: [Character: Int] = [:]
9+
10+
for char in s {
11+
countS[char, default: 0] += 1
12+
}
13+
14+
for char in t {
15+
countT[char, default: 0] += 1
16+
}
17+
18+
return countS == countT
19+
}
20+
}

0 commit comments

Comments
 (0)