Перейти к содержимому

Longest Common Subsequence (LCS): Optimal Substructure and the Recurrence | DSA Course L76

The Modern SDE

0:00 / 0:00

Longest Common Subsequence (LCS): Optimal Substructure and the Recurrence | DSA Course L76

5 просмотров · 10 дн. назад
The Modern SDE
1,3 тыс. подписчиков
5 просмотров · 10 дн. назад
Lecture 76 of the Complete DSA Course in Java by Engineer X · Part 4: Dynamic Programming, Greedy and Amortized Analysis. In this lecture • Three ways to measure how similar two strings are: substring, edit distance, common subsequence • Subsequence vs substring, and the precise definition with increasing indexes • Common subsequences, and why we say an LCS, not the LCS • Brute force checks all 2^m subsequences: exponential time • Prefixes as subproblems, and the optimal-substructure theorem with its proof • The recurrence for c[i, j], and how the input itself rules out subproblems • Plain recursion in Java: millions of calls for a few hundred subproblems • Interview: LCS vs longest common substring vs edit distance Chapters 0:00 Why compare sequences 1:12 Subsequence vs substring 3:17 Brute force is exponential 3:54 Optimal substructure 6:26 The recurrence 7:17 Overlapping subproblems 8:49 Interview: three look-alikes 9:36 Recap and quiz 10:50 Up next Book reference: Introduction to Algorithms (Cormen, Leiserson, Rivest, Stein), 4th edition, Section 14.4. The explanations, examples and code in this lecture are original. #DSA #Algorithms #DataStructures #Java #CodingInterview #EngineerX #LongestCommonSubsequence #LCS #DynamicProgramming #Java #CLRS