A traffic chart highlights its longest "spike": a run of neighboring points that strictly rises to a peak and then strictly falls. A spike has at least 3 points, with at least one point before the peak and at least one after it.
Write longestSpike(points) that returns the number of points in the longest spike, or 0 if there is none.
Input: points = [2,1,4,7,3,2,5] Output: 5
1, 4, 7, 3, 2 rises to 7 and falls.
Input: points = [2,2,2] Output: 0
Flat points never rise or fall.
0 <= points.length <= 1000000 <= points[i] <= 10^4Run 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 #599 Longest Rise and Fall in a Chart. 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.