#3795
Minimum Subarray Length With Distinct Sum At Least K
medium · 31.6% accepted · 76 likes · top 9%
array · hash table · sliding window
Description
You are given an integer array nums and an integer k.
Return the minimum length of a subarray whose sum of the distinct values present in that subarray (each value counted once) is at least k. If no such subarray exists, return -1.
Solution