Trains the technique from
LeetCode 213House Robber IIThis 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.
Vending kiosks stand in a circle around a plaza. Kiosk i will take crates[i] crates of stock tonight, and the array closes on itself: the last kiosk and the first kiosk stand side by side.
One van does the round, and it cannot serve two kiosks that stand next to each other, because the plaza only opens one bay at a time and neighbouring bays share a shutter. Serving no kiosk at all is allowed.
Return the largest number of crates the van can deliver in a single night.
Example 1
Serving the first and third kiosk delivers 7 plus 9 crates; the other legal pair, the second and fourth, only manages 9 in total.
Example 2
On a ring of three every kiosk touches both others, so the van can serve only one of them.
Example 3
Neither kiosk needs stock, so the van delivers nothing.
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 max_ring_restock(crates: list[int]) -> int:public int maxRingRestock(int[] crates)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.