Array:
1x
Dynamic Programming

Longest Increasing Subsequence (LIS)

Step 1 of 6

Given an array of numbers, find the longest subsequence that is strictly increasing. Unlike sorting, elements must keep their original relative order. A cornerstone DP problem used in patience sorting, version history analysis, and RNA structure prediction.

The Problem

A subsequence is a selection of elements that preserves original order but can skip elements. For [3, 10, 2, 1, 20], the LIS is [3, 10, 20] (length 3) — not [3, 10, 2, 20] because 2 < 10 breaks the increasing order.

3
10
2
1
20
LIS = [3, 10, 20]