33Edit distance (Levenshtein): the 2D dynamic programming pattern.▼hardGoogleMetaAmazon1 replies◆ premiumEdit distance is the canonical 2D string DP, behind spell-check, diff, and fuzzy matching. The signal is defining the subproblem and the insert/delete/replace recurrence. Here is the answer.Open full answer →
45Longest Common Subsequence (LCS) and the 2D DP family.▼mediumGoogleMetaAmazon1 replies◆ premiumLCS is the template 2D-sequence DP behind diff tools and bioinformatics. The signal is reconstructing the match/mismatch recurrence cold and not confusing subsequence (gaps allowed) with substring (contiguous). Here is the answer.Open full answer →
56Maximal Square: the 2D dynamic programming pattern on a grid.▼mediumGoogleMetaAmazon1 replies◆ premiumThe canonical grid DP where each cell depends on three neighbors at once. The signal interviewers want is the min-of-three recurrence, and the reason it has to be min. Here is the answer.Open full answer →