values. Call its **peak frequency** the largest number of times any single value occurs in it.
Return the length of the shortest contiguous segment of values whose peak frequency equals that of the whole array.values=[5, 1, 5, 3, 3, 2] → 2
The most frequent values, 5 and 3, each appear twice. Both 5s fit in a segment of length 3, and both 3s in the segment [3, 3] of length 2.
values=[2, 6, 6, 2, 6, 1] → 4
6 appears three times, at positions 1, 2 and 4, so the segment [6, 6, 2, 6] of length 4 is needed.
values=[8] → 1
values=[5, 1, 5, 3, 3, 2]
2
Run checks the first 3 tests in your browser. Submit checks all 95 tests on the server, hidden ones included.