Longest Increasing Subsequence (LIS)
The Longest Increasing Subsequence (LIS) problem is a foundational paradigm in sequence optimization and dynamic programming. The objective is formalized as follows:
Given an integer array of length , determine the maximum length of a subsequence such that all elements are sorted in a strictly increasing order.
A subsequence is derived by deleting zero or more elements from the original array while preserving the relative spatial ordering of the remaining elements.
Formalized Example
Consider the sequence:
Valid strictly increasing subsequences include:
Optimal Evaluation:
Video Explanation

Combinatorial Brute Force Intuition
A naive approach evaluates the entire state space of subsequences. At each index , a decision boundary emerges: either include (conditioned on it being strictly greater than the previously selected element) or exclude it.
This generates a state-space tree bounded by the power set of the array, yielding a total of possible subsets. The resulting time complexity is , which is computationally intractable for inputs where . This bottleneck motivates optimization via Dynamic Programming and Greedy/Binary Search strategies.
Approach 1: The Quadratic Dynamic Programming Model
Mathematical Formulation
Let represent the length of the LIS whose terminal element resides precisely at index .
For any given index , we scan all historical states where . If , the element at can structurally extend the optimal subsequence terminating at .
Recurrence Relation
Step-by-Step Execution Matrix
Input Instance:
Initialization:
| Target Index () | Element () | Valid Lookback Constraints Checked () | Candidate Evaluations () | State Mutation () |
|---|---|---|---|---|
| 0 | 3 | None | None | 1 |
| 1 | 10 | 2 | ||
| 2 | 2 | None | 1 | |
| 3 | 1 | None | 1 | |
| 4 | 20 | |