values. A number x from the array is isolated if it appears exactly once and neither x − 1 nor x + 1 appears in the array.
Return all isolated numbers in any order.values=[4, 9, 3, 12, 9, 15] → [12, 15]
4 and 3 are neighbours and 9 repeats. 12 and 15 each appear once, with none of 11, 13, 14 or 16 present.
values=[0] → [0]
A lone number is always isolated.
values=[6, 7, 7] → []
6 has the neighbour 7, and 7 repeats.
len(values) ≤ 10⁵values[i] ≤ 10⁶values=[4, 9, 3, 12, 9, 15]
[12, 15]
Run checks the first 3 tests in your browser. Submit checks all 147 tests on the server, hidden ones included.