values and a window width width. A window is any contiguous stretch of the array that is exactly width elements long.
Call a number *lonely* if it appears in exactly one window (how many times it repeats inside that window does not matter).
Return the largest lonely number, or -1 if there is none.values=[6, 2, 8, 4, 5], width=2 → 6
The windows are [6, 2], [2, 8], [8, 4], [4, 5]. Only 6 and 5, the numbers at the ends, show up in exactly one window; the larger one is 6.
values=[4, 7, 1, 4], width=3 → -1
The windows are [4, 7, 1] and [7, 1, 4]. 4 is in both, and so are 7 and 1, so no value qualifies.
values=[3, 3, 9], width=1 → 9
values) ≤ 50values[i] ≤ 50width ≤ len(values)values=[6, 2, 8, 4, 5], width=2
6
Run checks the first 3 tests in your browser. Submit checks all 108 tests on the server, hidden ones included.