File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 2
2
package main
3
3
4
4
func isAnagram (s string , t string ) bool {
5
- return frequency (s ) == frequency (t )
5
+ return frequencies (s ) == frequencies (t )
6
6
}
7
7
8
- func frequency (s string ) [26 ]int {
8
+ func frequencies (s string ) [26 ]int {
9
9
var f [26 ]int
10
10
for _ , r := range s {
11
11
f [r - 'a' ]++
@@ -16,14 +16,14 @@ func frequency(s string) [26]int {
16
16
// ちゃんとUnicodeに対応させるなら結合文字などを考慮する必要がある
17
17
// https://github.com/rihib/leetcode/pull/5#discussion_r1706198268
18
18
func isAnagramUnicode (s string , t string ) bool {
19
- frequency := make (map [rune ]int )
19
+ frequencies := make (map [rune ]int )
20
20
for _ , r := range s {
21
- frequency [r ]++
21
+ frequencies [r ]++
22
22
}
23
23
for _ , r := range t {
24
- frequency [r ]--
24
+ frequencies [r ]--
25
25
}
26
- for _ , n := range frequency {
26
+ for _ , n := range frequencies {
27
27
if n != 0 {
28
28
return false
29
29
}
You can’t perform that action at this time.
0 commit comments