A scroll performance test records how long each frame took, in milliseconds, in frames. A frame is smooth if it took at most budget milliseconds.
Write longestSmooth(frames, budget) that returns the length of the longest run of neighboring frames that are all smooth. Return 0 if no frame is smooth.
Input: frames = [12,16,40,10,11,9,16,33], budget = 16 Output: 4
Frames 3 to 6 (10, 11, 9, 16) are all at most 16 ms.
Input: frames = [50,60], budget = 16 Output: 0
No frame is smooth.
0 <= frames.length <= 2000001 <= frames[i], budget <= 1000Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #140 Longest Smooth Scroll Stretch. 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.