Longest increasing subsequence
A path has stones of different heights. You may jump forward to a strictly taller stone. How many stones can you visit?
For each length, remember the lowest stone on which a path of that length has ended. A lower ending leaves more possible jumps.
A strictly smaller ending can be extended. Equal heights cannot make an increasing jump.
For n stones the algorithm uses O(n log(n + 1)) comparisons and O(n) space.