Skip to content

Commit 0eaf729

Browse files
committed
refactor(Valid Anagram): 変数名を改善
1 parent 0534b84 commit 0eaf729

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

go/valid_anagram.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
package main
33

44
func isAnagram(s string, t string) bool {
5-
return frequency(s) == frequency(t)
5+
return frequencies(s) == frequencies(t)
66
}
77

8-
func frequency(s string) [26]int {
8+
func frequencies(s string) [26]int {
99
var f [26]int
1010
for _, r := range s {
1111
f[r-'a']++
@@ -16,14 +16,14 @@ func frequency(s string) [26]int {
1616
// ちゃんとUnicodeに対応させるなら結合文字などを考慮する必要がある
1717
// https://github.com/rihib/leetcode/pull/5#discussion_r1706198268
1818
func isAnagramUnicode(s string, t string) bool {
19-
frequency := make(map[rune]int)
19+
frequencies := make(map[rune]int)
2020
for _, r := range s {
21-
frequency[r]++
21+
frequencies[r]++
2222
}
2323
for _, r := range t {
24-
frequency[r]--
24+
frequencies[r]--
2525
}
26-
for _, n := range frequency {
26+
for _, n := range frequencies {
2727
if n != 0 {
2828
return false
2929
}

0 commit comments

Comments
 (0)