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 4f14395 commit 13be050Copy full SHA for 13be050
pullrequests/valid_anagram/step3.go
@@ -0,0 +1,32 @@
1
+//lint:file-ignore U1000 Ignore all unused code
2
+package validanagram
3
+
4
+func isAnagram_step3(s string, t string) bool {
5
+ return frequency(s) == frequency(t)
6
+}
7
8
+func frequency(s string) [26]int {
9
+ var f [26]int
10
+ for _, r := range s {
11
+ f[r-'a']++
12
+ }
13
+ return f
14
15
16
+// ちゃんとUnicodeに対応させるなら結合文字などを考慮する必要がある
17
+// https://github.com/rihib/leetcode/pull/5#discussion_r1706198268
18
+func isAnagram_unicode_step3(s string, t string) bool {
19
+ frequency := make(map[rune]int)
20
21
+ frequency[r]++
22
23
+ for _, r := range t {
24
+ frequency[r]--
25
26
+ for _, n := range frequency {
27
+ if n != 0 {
28
+ return false
29
30
31
+ return true
32
0 commit comments