mirror of
https://git.wolves.top/wolves/leetcode.git
synced 2025-11-04 17:26:32 +08:00
init
This commit is contained in:
19
25/06/3442.go
Normal file
19
25/06/3442.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
func maxDifference(s string) int {
|
||||
m := make(map[rune]int)
|
||||
|
||||
maxOdd := 0
|
||||
minEven := len(s)
|
||||
for _, c := range s {
|
||||
m[c]++
|
||||
}
|
||||
for _, v := range m {
|
||||
if v%2 == 1 {
|
||||
maxOdd = max(maxOdd, v)
|
||||
} else {
|
||||
minEven = min(minEven, v)
|
||||
}
|
||||
}
|
||||
return maxOdd - minEven
|
||||
}
|
||||
Reference in New Issue
Block a user