NewProject Coding is here — build features and fix bugs in real codebases with an AI assistantSee what's new

(This question is a variation of the LeetCode question 76. Minimum Window Substring. If you haven't completed that question yet, it is recommended to solve it first.)

Given an array arr of n positive integers and an integer k, a subarray is considered good if it contains at least k distinct integers. Find the minimum length of a good subarray. If no good subarray exists, return -1.

Test Cases
Input
Output
Expected