Foundations
Linear Structures
Hashing
Array and String Patterns
Recursion, Search, and Sorting
Problem Solving Patterns
Algorithm Searching
Sorting Algorithms
Array Algorithms
Grid Algorithms
Linear Structure Algorithms
Hashing Algorithms
Recursion and Backtracking
Greedy Algorithms
Tree and Heap Algorithms
Graph Algorithms
Dynamic Programming Algorithms
String Algorithms
Math Algorithms
Keyboard ready
Space plays. Arrow keys step. R restarts.
LAB Longest Increasing Subsequence Lab
Dynamic Programming
Problem shape
Intermediate
4
8
15
16
23
42
Core idea
Track the smallest possible tail value for increasing subsequences of each length.
Step 1 / 5
Problem shape
Dynamic Programming Intermediate
Longest Increasing Subsequence
Welcome to the Longest Increasing Subsequence algorithm lab. Track the smallest possible tail value for increasing subsequences of each length. Use it when: Use for sequence ordering and minimum-removal style problems. The time complexity is O(n log n), and the space complexity is O(n). The pseudocode is: tails = [] for x in nums i = lower_bound(tails, x) tails[i] = x answer = length(tails) As you practice, track the state that changes and the condition that makes the algorithm stop.
Time
O(n log n)
Space
O(n)
Pseudocode
tails = []
for x in nums
i = lower_bound(tails, x)
tails[i] = x
answer = length(tails) 1.0x