VFlash: Fast, Accurate Visual Planning via Flash Primitive Decoding
u_Unrolled
DSA for AI/ML · Module 12: Dynamic programming

Lesson 12.5 of 16 in this module Unrolled Pro

Longest Increasing Subsequence

The length of the longest strictly increasing subsequence (not necessarily contiguous). From checking all 2^n subsequences, to the DP where lis[i] is the longest increasing subsequence ending at i (O(n²)), to patience sorting: keep, for each length, the smallest possible tail, updated by binary search (O(n log n)). Then recovering the subsequence itself, non-decreasing sequences, nesting envelopes in two dimensions, and the longest run of checkpoints whose metric kept improving.

about 10 min 3 Python examples 2 quick checks

Problem. Given an integer array nums, return the length of the longest strictly increasing subsequence. A subsequence keeps the original order but may skip elements.

text
nums = [10, 9, 2, 5, 3, 7, 101, 18]   →   4      (2, 3, 7, 18 or 2, 5, 7, 101)
nums = [7, 7, 7, 7]                   →   1

Unlike a subarray, a subsequence can skip, so there are 2ⁿ of them. The DP state that makes it tractable is "the longest increasing subsequence ending at position i": whatever came before i in that subsequence ended at some smaller value earlier.

ML context. Monotone structure in noisy sequences: the longest run of checkpoints whose validation score kept improving (Change D) shows how often training made real progress; aligning two orderings (how much of a predicted ranking agrees with the true one) reduces to an increasing subsequence; and the O(n log n) "smallest tail per length" trick is a compact example of maintaining a sorted summary with binary search (module 05).


1. Step 1: Clarify

That's the preview. Modules 00–01 are free; this lesson is part of Unrolled Pro.
Staff AI & Pro Tier Lesson

Unlock "Longest Increasing Subsequence"

The foundations are free forever. Unrolled Pro unlocks the complete lesson, production architectures, and 55 battle-tested ML system design case studies.

Everything included with Pro:
All 234+ Deep-Dive Lessons across transformer internals, inference, RAG & agents
55 Staff-Level ML & System Design Case Studies with mathematical capacity estimates
AI Engineer Sheet & Exercises with worked solutions, self-checks, and code
100 Landmark Research Papers guided walkthroughs & progress tracking
14-Day Money-Back Guarantee — 100% full refund if you aren't satisfied
View Plans & Unlock All Lessons

From ₹167/mo (~$2/mo) · Cancel anytime · Instant activation

100% Risk-Free: 14-day no-questions-asked money-back guarantee