Longest Increasing Subsequence

Learn about another variation of the string-based problems that are solved using dynamic programming.

Problem statement

The Longest Increasing Subsequence (LIS) problem requires you to find the length of the longest subsequence of a given sequence such that all elements of the subsequence are sorted in increasing order.

For example, the length of LIS for {10, 9, 3, 5, 4, 11, 7, 8} is 4 and LIS is {3, 4, 7, 8}.

Solution: Naïve approach

The simplest approach is to try to find all increasing subsequences and then returning the maximum length of the longest increasing subsequence.

  • Time complexity : O(
...