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 5ec20a7 commit f18ca9fCopy full SHA for f18ca9f
go/242-Valid-Anagram.go
@@ -0,0 +1,36 @@
1
+func isAnagram(s string, t string) bool {
2
+
3
+ if len(s) != len(t) {
4
+ return false
5
+ }
6
7
+ s_map := map[rune]int{}
8
+ t_map := map[rune]int{}
9
10
+ for _, c := range s {
11
+ if _, ok := s_map[c]; !ok {
12
+ s_map[c] = 1
13
+ } else {
14
+ s_map[c] += 1
15
16
17
18
+ for _, c := range t {
19
+ if _, ok := t_map[c]; !ok {
20
+ t_map[c] = 1
21
22
+ t_map[c] += 1
23
24
25
26
27
+ if s_map[c] != t_map[c] {
28
29
30
31
32
+ return true
33
34
+}
35
36
0 commit comments