Shortest run reaching a total, with negatives
Given a non-empty list of integers nums, which may hold negatives, and a positive integer k, return the length of the shortest non-empty contiguous subarray whose sum is at least k. Return -1 if no subarray reaches k.
The negatives break the usual sliding window: dropping a value from the left can raise the sum. Aim for O(n).
Besides the tests, one large input (5,500 numbers) with a ~150 ms limit (scaled to your device's speed): brute force won't pass.
Examples
shortest_reaching([3,-2,4], 5)→3shortest_reaching([2,1,1], 5)→-1shortest_reaching([3,-4,2,5], 7)→2