menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Data Science News

>

862. Short...
source image

Dev

1M

read

155

img
dot

Image Credit: Dev

862. Shortest Subarray with Sum at Least K

  • Given an integer array nums and an integer k, return the length of the shortest non-empty subarray of nums with a sum of at least k.
  • The solution involves using a sliding window approach combined with prefix sums and a monotonic queue.
  • The time complexity of the solution is O(n), where n is the length of the input array.
  • The space complexity is O(n) due to the prefix sum array and the deque used to store indices.

Read Full Article

like

9 Likes

For uninterrupted reading, download the app