1742. Maximum Number of Balls in a Box

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1742

class Solution:
    def countBalls(self, lowLimit: int, highLimit: int) -> int:
        cnt = [0] * 50
        for x in range(lowLimit, highLimit + 1):
            y = 0
            while x:
                y += x % 10
                x //= 10
            cnt[y] += 1
        return max(cnt)