Trains the technique from
LeetCode 1823Find the Winner of the Circular GameThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A pottery studio seats its trainees in a ring around the kiln. There are apprentices of them, numbered 1 upwards going clockwise, so the highest number sits shoulder to shoulder with number 1.
The tutor thins the ring one trainee at a time. Begin at apprentice 1 and count step seats clockwise, counting the apprentice you begin on as one. Whoever you finish on hands over their tools and leaves the ring. Begin the next count from the apprentice sitting immediately clockwise of the one who just left, count step seats again, and carry on the same way. Once the ring has grown short the counting simply keeps going round it, so the same apprentice can be counted more than once inside a single count. When only one apprentice is still seated, that apprentice keeps the wheel for the rest of the day.
Return the seat number of the apprentice who keeps the wheel.
Example 1
The counts take out apprentices 3, 6, 2, 7, 5 and 1 in that order, and apprentice 4 is the one still seated.
Example 2
The counts clear out apprentices 4, 8, 3, 9, 6, 5, 7 and last of all 2, which leaves apprentice 1 seated.
Example 3
Each count stops on the apprentice it begins with, so seats 1 through 5 clear out in order and apprentice 6 keeps the wheel.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def last_apprentice_at_the_kiln(apprentices: int, step: int) -> int:public int lastApprenticeAtTheKiln(int apprentices, int step)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.