Streak of Positive Days
Halcyon Bank's fund factsheets quote a fund's longest winning run: the greatest number of trading days in a row on which the fund gained. A day counts as a winning day only if its return was strictly above zero. A flat day, exactly zero, is not a gain, and it ends a run just as firmly as a loss does. A fund that never gained on any day quotes a run of 0.
Task: Print the length of the fund's longest run of consecutive winning days.
Input
The first line holds a single integer n, the number of trading days. Each of the next n lines holds one day's return, in date order. A return may be negative, zero or positive, and may carry decimals.
Output
One line holding the length of the longest run, as a whole number. If no day gained, print 0.
Example:
Input:
7
1
2
-1
3
4
5
-2
Output:
3
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in