Skip to main content

Cracking Longest Common Subsequence: A Journey from Confusion to Clarity

· 8 min read
Mahmut Salman
Software Developer

I thought I had DP figured out. I'd solved house robber with that sweet max(rob_this_house + dp[i-2], skip_this_house) logic. I'd reversed linked lists by imagining "the rest is already solved." But when I faced Longest Common Subsequence, all my mental models fell apart.

No decision tree. No "imagine the rest" logic. No clever way to use previous answers. Just... confusion.

Here's how I finally cracked it.