| https://leetcode.com/problems/maximum-number-of-balls-in-a-box/description/ | Easy |
|---|
class Solution {
fun countBalls(lowLimit: Int, highLimit: Int): Int {
val count = IntArray(46)
var maxCount = 0
for (i in lowLimit..highLimit) {
var x = i
var s = 0
while (x > 0) {
s += x % 10
x /= 10
}
count[s]++
if (count[s] > maxCount) maxCount = count[s]
}
return maxCount
}
}