The problem descriptions says:
Given [10, 9, 2, 5, 3, 7, 101, 18].
The longest increasing subsequence is [2, 3, 7, 101], therefore the length is 4.
However, this is incorrect. The provided subsequence is missing the 5 that has mysteriously disappeared.
In fact, the longest increasing subsequence here is is [3, 7, 101] of length 3.
Am I missing something or is the question phrased inappropriately?
You are interpreting the problem as the problem of finding the longest increasing contiguous subsequence. However, for the longest increasing subsequence problem the elements in the subsequence can be spaced out or can have gaps in between. As long as the elements in the subsequence are in increasing order, we are fine. Hope that helps.