Tap here to switch tabs
Problem
Submissions

Problem: Minimum Subarray Length With Distinct Sum At Least K

med
30 min
Try to solve the Minimum Subarray Length With Distinct Sum At Least K problem.

Statement

Given an array of positive integers nums and a positive integer k.

Return the minimum length of a contiguous subarray of nums such that the sum of all unique elements in that subarray is at least k. If no such subarray exists, return −1-1.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5

  • 1≤1 \leq k ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Subarray Length With Distinct Sum At Least K

med
30 min
Try to solve the Minimum Subarray Length With Distinct Sum At Least K problem.

Statement

Given an array of positive integers nums and a positive integer k.

Return the minimum length of a contiguous subarray of nums such that the sum of all unique elements in that subarray is at least k. If no such subarray exists, return −1-1.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5

  • 1≤1 \leq k ≤109\leq 10^9