Trains the technique from
LeetCode 2150Find All Lonely Numbers in the ArrayThis 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 bike-share audit lists the dock every bike was returned to yesterday. The list docks holds one dock number per return, so a dock number appears once for each bike returned to it.
Docks are numbered so that dock d - 1 and dock d + 1 are the two docks standing either side of dock d. Call a dock number isolated when it appears exactly once in docks and neither d - 1 nor d + 1 appears in docks at all.
Return every isolated dock number, in ascending order. Return an empty list when there is none.
Example 1
Dock 7 was used once and docks 6 and 8 are absent, and dock 42 was used once with 41 and 43 absent. Docks 19 and 20 stand beside each other and both appear, so neither qualifies.
Example 2
Dock 3 was used once with 2 and 4 absent. Dock 10 was used twice, and docks 5 and 6 sit next to each other.
Example 3
Dock 42 appears twice, so it is not isolated and nothing is reported.
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 isolated_docks(docks: list[int]) -> list[int]:public List<Integer> isolatedDocks(int[] docks)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.