Skip to main content

15 posts tagged with "Algorithms"

Algorithm problems and solutions

View All Tags

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.

When DP Gets Messy: A Student's Journey Through Delete and Earn

· 10 min read
Mahmut Salman
Software Developer

A dialogue between Professor Chen and Alex, a senior Computer Science student, as they unravel why some DP problems resist the standard recursive → memoization → tabulation pipeline.


The Student's Confusion

Alex: [walks into office hours with laptop open] Professor Chen, I'm really confused about this LeetCode problem I'm working on. I thought I understood DP, but something's not clicking.

Professor Chen: Let's see what you've got. Walk me through it.

Alex: It's LC 740: Delete and Earn. Here's the problem: