Solved LeetCode program · 633 of 1,000
#0862 · Shortest Subarray with Sum at Least K
Original English source
The numbers is a list of 2, -1, and 2. The target is 3. The last is the last position of numbers. The best is last plus 2.
For every start from 0 to last.
The total is 0.
For every tail from start to last.
The value is item tail of numbers. Add value to total.
If total is at least target.
The span is tail minus start plus 1. If span is less than best, set best to span. stop.
Show best.
Expected stdout
3