Ctrl K

Busiest Digit-Sum Bin

Easy
A raffle prints tickets numbered from first to last inclusive. Tickets are sorted into bins: a ticket goes to the bin whose number equals the sum of the digits of the ticket number. For instance, ticket 405 goes to bin 4 + 0 + 5 = 9. There are as many bins as needed. Return how many tickets end up in the fullest bin.
Example 1
first=8, last=17 → 2

The digit sums are 8, 9, 1, 2, 3, 4, 5, 6, 7, 8. Bin 8 gets two tickets, 8 and 17; every other bin gets one.

Example 2
first=100, last=100 → 1

A single ticket, alone in bin 1.

Example 3
first=1, last=30 → 4
Constraints
  • 1 ≤ first ≤ last ≤ 10⁵
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsEven Piles of Cards EasyPairs of Equal Values EasyCoprime Digit Pairs EasyShuffle the Digits Into a Power of Two MediumPairs Balanced by Their Mirrors Medium
loading Python…
Input
first=8, last=17
Expected
2

Run checks the first 3 tests in your browser. Submit checks all 86 tests on the server, hidden ones included.