Maximum Number of Balls in a Box LeetCode solution in Python

1
class Solution:
2
def countBalls(self, lowLimit: int, highLimit: int) -> int:
3
boxes = [0] * 100
4

5
for i in range(lowLimit, highLimit + 1):
6

7
# For the current number "i", convert it into a list of its digits.
8
# Compute its sum and increment the count in the frequency table.
9

10
boxes[sum([int(j) for j in str(i)])] += 1
11

12
return max(boxes)

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0