1

We have given array of $n$ integers in the range $[1, k]$. We want to design algorithm that can modify the array and also find the length of the shortest subarray containing at least one of each integers in the range $[1,k]$. $k$ can go up to 50, but $n$ can be large number, up to 100000.

I know that the offline version with fixed array can be solved in $O(NK)$ with sliding window across the array, but I don't know how to extend this or another algorithm to make it work online.

Please give me some hints where to start.

someone12321
  • 1,428
  • 15
  • 27

0 Answers0