Trains the technique from
LeetCode 673Number of Longest Increasing SubsequenceThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A river gauge reports its level against a datum, so a reading may be negative. marks holds one reading per hour, earliest hour first.
A rising run is a pick of one or more readings, kept in the order the hours were logged, in which each reading picked is strictly above the one picked before it. The hours picked need not be consecutive. Two runs are different when they pick different hours, even if the readings they pick happen to match.
Return how many rising runs are as long as the longest rising run in the log.
Example 1
The longest rising runs pick three hours: -14, 62, 90 and -14, 5, 90 and -14, 5, 41.
Example 2
No reading is strictly above another, so the longest run picks a single hour, and each of the three hours gives one such run.
Example 3
The longest runs pick three hours: -20 then -3 then the later 46, and -8 then -3 then that same 46.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def longest_rise_count(marks: list[int]) -> int:public int longestRiseCount(int[] marks)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.