Skip to main content

12 posts tagged with "Algorithms"

Algorithm problems and solutions

View All Tags

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:

The Dynamic Programming Learning Journey: A Conversation

· 9 min read
Mahmut Salman
Software Developer

A dialogue between an engineer learning DP and a professor clarifying the optimal learning path

The Question

Engineer: Professor, I've been breaking down how to approach dynamic programming problems, and I want to validate my thinking. Here's my approach:

  1. First, I solve the problem using recursion in the worst possible way - not worrying about time or space complexity at all
  2. Then, I optimize that recursive solution with memoization, which gives me a top-down DP solution
  3. Finally, I convert it to bottom-up DP for an even better solution in terms of both time and space complexity

Am I thinking about this correctly? Or am I missing something critical?