A flash sale dashboard records how many orders came in each second in orders. The team wants to know the shortest burst of consecutive seconds that brought in at least goal orders.
Write shortestBurst(orders, goal) that returns the length of the shortest run of neighboring seconds whose total is at least goal. If no run reaches the goal, return 0.
Input: orders = [2,3,1,2,4,3], goal = 7 Output: 2
[4, 3] reaches 7 in two seconds.
Input: orders = [1,1,1], goal = 5 Output: 0
All three seconds together only make 3 orders.
0 <= orders.length <= 1000001 <= orders[i] <= 10^41 <= goal <= 10^9Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #136 Shortest Burst Reaching a Goal. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.