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 8c0007e commit bb110c5Copy full SHA for bb110c5
valid-anagram/SamTheKorean.go
@@ -0,0 +1,22 @@
1
+// TC : O(n) : it iterates for the length of nums
2
+// SC : O(n) : we make hashmap as the size of the given string
3
+func isAnagram(s string, t string) bool {
4
+ if len(s) != len(t) {
5
+ return false
6
+ }
7
+
8
+ letterCounts := make(map[rune]int)
9
10
+ for _, ch := range s {
11
+ letterCounts[ch]++
12
13
14
+ for _, ch := range t {
15
+ letterCounts[ch]--
16
+ if letterCounts[ch] < 0 {
17
18
19
20
21
+ return true
22
+}
0 commit comments