Algorithm · IBM · Medium
Requirements Implement the following function: arr is a list of integers, and k is an integer. Return the length of the shortest contiguous, non-empty subarray that meets the distinct-value requirement. Return -1 when no qualifying subarray can be found. Confirm whether a qualifying window must contain exactly k distinct integers or at least k distinct integers. The examples below use the at-least-k interpretation. Examples Example 1 The subarray [2, 1, 3] contains three…
Checking your access…