Trains the technique from
LeetCode 300Longest 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 weather station files one temperature anomaly per year, in tenths of a degree, and an anomaly may be below zero. anomalies lists them oldest year first.
An analyst wants to publish as many of those years as possible in the order they happened, under one rule: each published anomaly has to be strictly above the one published before it. Years may be left out freely, so the published years need not be neighbours in the list.
Report how many years the largest publishable pick holds.
Example 1
Publishing the years holding -3, -1, 4 and 15 keeps every step above the one before it. No pick of five years manages that.
Example 2
Equal anomalies cannot follow one another because each step has to be strictly above the last, so only a single year is publishable.
Example 3
Every later anomaly sits below its predecessor, so no two years can be published together.
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_rising_pick(anomalies: list[int]) -> int:public int longestRisingPick(int[] anomalies)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.