A price chart stores one closing price per day in prices. An analyst wants the longest list of days, in date order but not necessarily next to each other, where every price is strictly higher than the one before.
Write longestRise(prices) that returns the length of that list.
Input: prices = [6,2,8,3,9,4,10] Output: 4
For example 2, 3, 4, 10.
Input: prices = [5,5,5] Output: 1
Equal prices are not a rise, so any single day is the best.
1 <= prices.length <= 2500-10000 <= prices[i] <= 10000Run 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 #524 Longest Rising Price Sequence. 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.