Search⌘ K
AI Features

Solution: Shortest Subarray with Sum at Least K

C# solution for the Shortest Subarray with Sum at Least K problem using the Knowing What to Track pattern.

Statement

Given an integer array nums and an integer k, return the length of the shortest non empty contiguous subarray of nums whose sum is at least k. If no such subarray exists, return -1.

Constraints:

  • 11 \leq nums.length 105\leq 10^5

  • ...