Algorithm · Uber · Medium
Requirements Given a positive-integer array arr and an integer k. Call a subarray good when it includes no fewer than k unique values. Return the size of the smallest good subarray. Return −1 when arr contains fewer than k unique values in total. Limits: 1 ≤ arr.length ≤ 10^5, 1 ≤ arr[i] ≤ 10^6, 1 ≤ k ≤ arr.length. Examples Preparation Work through LC 992, which counts subarrays having exactly K distinct values. Once that technique is familiar, this variation should take…
Checking your access…