mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-08-05 21:20:59 +08:00
18 lines
302 B
Go
18 lines
302 B
Go
package leetcode
|
|
|
|
func countBalls(lowLimit int, highLimit int) int {
|
|
buckets, maxBall := [46]int{}, 0
|
|
for i := lowLimit; i <= highLimit; i++ {
|
|
t := 0
|
|
for j := i; j > 0; {
|
|
t += j % 10
|
|
j = j / 10
|
|
}
|
|
buckets[t]++
|
|
if buckets[t] > maxBall {
|
|
maxBall = buckets[t]
|
|
}
|
|
}
|
|
return maxBall
|
|
}
|