992. Subarrays with K Different Integers
992. Subarrays with K Different Integers
Description

Solution
Quite tricky solution using two pointers, that we can fix the right pointer then move the left pointer to check the subarrays with less equals k elements. Then we can get subarray number by number of array with less equals k+1 elemens - number of array with less equals k+1 elemens.
Code
1 | class Solution { |

All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.

