Senior Dynamic Programming DSA & Coding Interviews

Explain Longest Common Subsequence (LCS) for interviews.

Short answer: 2-D DP: if s[i]==t[j], dp[i][j] = dp[i-1][j-1]+1 else max(skip either char). Classic O(m*n) table; can compress to two rows for space.

Common follow-ups

  • Print the LCS string
  • Longest Common Substring (different recurrence)
  • Edit Distance
Contrast subsequence (not contiguous) vs substring (contiguous) immediately.
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details