[Verse 1] Array scattered like dominoes, no pattern in sight Need to find the longest chain that climbs upward right Not consecutive indices, just values that ascend Dynamic programming swoops in to comprehend Build a table where each cell holds maximum length From start to current position, that's our secret strength [Chorus] LIS, LIS, longest increasing subsequence Dynamic table, optimal reference Bottom-up or memoized descent Length and sequence, both elements LIS, LIS, polynomial time complexity Order n-squared, that's our guarantee [Verse 2] For each element, scan backwards through the chain Find all smaller values, calculate the gain Take the maximum length found plus one more Store it in our table, that's what DP's for Patience sorting visualizes with playing cards Binary search optimization cuts time by yards [Chorus] LIS, LIS, longest increasing subsequence Dynamic table, optimal reference Bottom-up or memoized descent Length and sequence, both elements LIS, LIS, polynomial time complexity Order n-squared, that's our guarantee [Bridge] Greedy approach with binary insertion Tails array maintains perfectersion Replace or append, logarithmic search O(n log n) makes algorithmsurch Reconstruct path with parent pointers Backtrack through our optimal joiners [Verse 3] Applications everywhere from box stacking high To scheduling tasks that multiply RNA folding, patience games too Dilworth's theorem proves what subsequences do Width equals height in our partial order LIS reveals the algorithmic border [Chorus] LIS, LIS, longest increasing subsequence Dynamic table, optimal reference Bottom-up or memoized descent Length and sequence, both elements LIS, LIS, polynomial time complexity Now you've mastered the dependency
← Longest common subsequence | Knapsack (0/1 and unbounded) →