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 dbba78c commit 79657baCopy full SHA for 79657ba
valid-anagram/youngDaLee.go
@@ -0,0 +1,44 @@
1
+package youngDaLee
2
+
3
+import "strings"
4
5
+func isAnagram(s string, t string) bool {
6
+ if len(s) != len(t) {
7
+ return false
8
+ }
9
10
+ if s == t {
11
+ return true
12
13
14
+ sDict := make(map[string]int)
15
+ sList := strings.Split(s, "")
16
+ for _, data := range sList {
17
+ if num, ok := sDict[data]; ok {
18
+ sDict[data] = num + 1
19
+ } else {
20
+ sDict[data] = 1
21
22
23
24
+ tList := strings.Split(t, "")
25
+ for _, data := range tList {
26
27
+ sDict[data] = num - 1
28
29
30
31
32
+ if sDict[data] < 0 {
33
34
35
36
37
+ for _, num := range sDict {
38
+ if num != 0 {
39
40
41
42
43
44
+}
0 commit comments