queue. One operation deletes three elements from the front of the array, or all of the remaining ones if fewer than three are left.
Return the smallest number of operations after which no value appears in the array more than once. An empty array has no repeats.queue=[5, 1, 5, 2, 8, 3, 2] → 2
After the first cut [2, 8, 3, 2] is left and 2 repeats. After the second only [2] is left, with no repeats.
queue=[9, 9] → 1
One cut removes both items; an empty list has no repeats.
queue=[4, 7, 1] → 0
There are no repeats to begin with.
queue=[5, 1, 5, 2, 8, 3, 2]
2
Run checks the first 3 tests in your browser. Submit checks all 118 tests on the server, hidden ones included.