class Solution {
public int countBalls(int l, int r) {
int[] box = new int[50];
int max = 0;
for (int i = l; i <= r; i++) {
int num = getNum(i);
box[num]++;
max = Math.max(box[num], max);
}
return max;
}
int getNum(int n) {
int res = 0;
while (n > 0) {
res += n % 10;
n /= 10;
}
return res;
}
}
标签:10,盒子,int,res,小球,1742
From: https://www.cnblogs.com/eiffelzero/p/16919557.html