Loading...
Loading...
Loading...
A warehouse scans n items in a row. A stretch of k items is clean when no item code appears twice in it. Count the clean stretches.
Example
Input
6 3 1 2 1 3 4 4
Output
2
The stretches 2 1 3 and 1 3 4 are clean. The others repeat a code.
Try the problem first. Open one hint at a time.
A stretch is clean when the number of different codes equals k.
A set removes repeated codes.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor