Tap here to switch tabs
Problem
Submissions

Problem: Shortest Subarray with Sum at Least K

med
30 min
Try to solve the Shortest Subarray with Sum at Least K problem.

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:

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

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

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Shortest Subarray with Sum at Least K

med
30 min
Try to solve the Shortest Subarray with Sum at Least K problem.

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:

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

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

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