lc-go/solutions/35/q3541/solution.go
2026-01-13 00:14:04 +09:00

22 lines
344 B
Go

package q3541
func maxFreqSum(s string) int {
freqs := [26]int{}
for i := range len(s) {
freqs[s[i]-'a']++
}
max1, max2 := 0, 0
for i, freq := range freqs {
c := byte(i + 'a')
switch c {
case 'a', 'e', 'i', 'o', 'u':
max1 = max(max1, freq)
default:
max2 = max(max2, freq)
}
}
return max1 + max2
}
var _ = maxFreqSum