Trains the technique from
LeetCode 2560House Robber IVThis 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.
Readings are given as nums. A pick takes at least k of them, and no two picked readings may sit next to each other in the list.
A pick's ceiling is the largest reading it takes. Return the smallest ceiling any pick can have.
Example 1
The readings 3 and 6 sit at positions 1 and 5, so they are not next to each other, and taking them gives a ceiling of 6. A ceiling of 3 leaves only the single reading 3 available, which is one short of the two wanted.
Example 2
Two readings must be taken and the only non-neighbouring pair is the two ends, both a billion.
Example 3
Every reading is 1, and three can be taken at positions 0, 2 and 4.
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 min_capability(nums: list[int], k: int) -> int:public int minCapability(int[] nums, int k)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.