Trains the technique from
LeetCode 3920Maximize Fixed Points After DeletionsThis 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 log holds the readings nums in the order they were taken. An auditor may delete any readings, including none of them. Deleting a reading closes the gap, so the readings that remain keep their relative order and are renumbered from 0.
A remaining reading is settled when its value equals its slot in the shortened log. Return the largest number of settled readings the auditor can leave behind.
Example 1
Deleting the reading 2 leaves 0, 1, 4 in slots 0, 1 and 2. The readings 0 and 1 then sit at their own slots, so two readings are settled.
Example 2
Deleting the first two readings leaves 2, 1, 0 in slots 0, 1 and 2, where none is settled. Deleting the last four leaves 4 alone, which is not settled either. Keeping all five puts the reading 2 in slot 2, which settles one reading.
Example 3
Only slot 0 can hold a reading of 0, so at most one reading is settled however many are deleted.
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 most_settled_slots(nums: list[int]) -> int:public int mostSettledSlots(int[] nums)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.