Leetcode 862. Shortest Subarray with Sum at Least K

Input: nums = [1], k = 1
Output: 1
Input: nums = [1,2], k = 4
Output: -1
Input: nums = [2,-1,2], k = 3
Output: 3
  • 1 <= nums.length <= 105
  • -105 <= nums[i] <= 105
  • 1 <= k <= 109
  1. create two loop and sum them together to find the shortest path.
  2. TLE for the run time

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store