Practice Discrete Math

Algorithms / Lis Depth

Least You Need to Know: Longest Increasing Subsequence, Tails, and Reconstruction Intuition

LIS questions test whether you can separate the exact subsequence from the summary needed for its length. The two classic views are `dp[i]` for subsequences ending at `i` and the tails-array idea for faster length computation.

The least you need to know

Key notation

dp[i] LIS length ending at position `i`
tails[len] smallest possible tail value of an increasing subsequence of that length
lower_bound first position with value at least the target

Tiny worked example

  • In the `O(n^2)` DP, compute `dp[i] = 1 + max(dp[j])` over earlier indices `j` with `a[j] < a[i]`.
  • In the faster method, maintain the smallest possible tail for each subsequence length and replace tails using binary search.

Common mistakes

How to recognize this kind of problem

Start practice