This is Longest Increasing Subsequence from LeetCode. Given an array of integers, find the length of the longest strictly increasing subsequence. For [10, 9, 2, 5, 3, 7, 101, 18], the answer is 4 because the longest strictly increasing subsequence is [2, 3, 7, 101] (length 4).
Before reading on, try to think: why can't you just greedily pick the smallest elements? Read the problem statement carefully, noting the constraints. Try to identify the recursive structure before looking at the solution.