Ctrl K

Growing Handouts Around the Circle

Easy
A host hands out supply stickers to people children sitting in a circle. The first child gets 1 sticker, the second gets 2, and so on: each handout is one sticker larger than the previous one. After the last child, the host goes back to the first without resetting the count, so the first child gets people + 1 in the second round. When there are not enough stickers left for a full handout, the child whose turn it is takes everything that remains, and the handout ends. Return an array of length people with the number of stickers each child ends up with.
Example 1
supply=12, people=3 → [5, 4, 3]

First round: 1, 2, 3 (6 left). Second round: the first person gets 4 (2 left), the second is due 5 but gets the last 2. Result [5, 4, 3].

Example 2
supply=4, people=5 → [1, 2, 1, 0, 0]

The first person gets 1, the second 2, the third the remaining 1, and the rest get nothing.

Example 3
supply=1, people=1 → [1]
Constraints
  • 1 ≤ supply ≤ 10⁹
  • 1 ≤ people ≤ 1000
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsSum of Binary Strings EasyFold the Digits Down to One EasyCounting Off by Threes and Fives EasyAdding Long Numbers in Strings EasyOdd Counters After the Presses Easy
loading Python…
Input
supply=12, people=3
Expected
[5, 4, 3]

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