New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Longest Peak #258
Comments
Cool problem. I noticed that the examples never tested a scenario where a peak is ended by an immediate uphill (you always had repeated numbers doing this job). Edited some of the plateaus out of the last example to remedy this. |
It seems to be inferred but not directly said that the decline of the peak must be the same length as the incline. Is that correct? |
@xanderyzwich Doesn't have to be - check out the [2, 2, 3, 2] example |
@mrumiker That's a run of 3 [2, 3, 2] with rise and fall both being 1 |
@xanderyzwich You're right! From the instructions, I interpret a peak as any increasing run of numbers followed immediately by a decreasing run. Any "plateau" (a pair of equal numbers) would end the peak, as would any increasing pair occurring on the downhill portion. |
So it seems like I'm wrong if this one is right
|
closed by #272 |
Sorry about the mixup on this - I realize my comment where I said "You're right!" wasn't clear. I was trying to say "You're right about the example I mentioned, but I still don't think the increase and decrease have to be equal based on what the directions say." I wish I'd actually noticed the example that proved my point! |
Longest Peak
Write a function that takes in an array of integers and returns the length of the longest peak in the array.
A peak is defined as adjacent integers in the array that are strictly increasing until they reach a tip (the highest value in the peak), at which point they become strictly decreasing. At least three integers are required to form a peak.
I will make this abundantly clear in the examples.
Business Rules/Errata
Examples
The text was updated successfully, but these errors were encountered: