Код: Выделить всё
I encountered this question in an interview:
Примеры:
nums = [1, 0, 1, 0, 1] и k = 2
Решение – 3, а именно:
Код: Выделить всё
[1, 0, 1, 0]
[0, 1, 0, 1]
[1, 0, 1, 0, 1]
These subarrays have at least 2 pairs of elements which are (0, 1).
nums = [2, 2, 2, 2, 2, 2] and k = 3
The solution is 1.
С уважением,
Подробнее здесь: https://stackoverflow.com/questions/788 ... duplicates