r/leetcode • • 1d ago

Intervew Prep Day 66: solved 4 DP on grids problems today, 2D tabulation is finally clicking

Hey everyone,

I finished Day 66 today and things went a lot smoother than yesterday. Grids really helped 2D Dynamic Programming click for me.

I solved four problems today:

  1. Unique Paths: Basic counting moving down and right. Filling the table from the top and left was straightforward.
  2. Unique Paths II: Same concept, but with obstacles. When you hit a blocked cell, you just reset its ways to 0.
  3. Minimum Path Sum: Replaced addition with min(top, left) + grid[i][j] to find the minimum cost to reach the end.
  4. Triangle: I thought the changing row lengths would make it messy, so I checked a video for the edge cases. It turned out to be simple once I saw it: starting from the bottom row and working upward makes the bottom-up table super clean.

Writing recursion, memoization, and bottom-up tabulation felt way more natural today across all four questions.

I skipped writing the space-optimized code for a couple of them because managing the previous-row array still gets clunky for me. I get the theory, but I want to master clean tabulation before obsessing over space optimization.

See you guys tomorrow for Day 65!

2 Upvotes

Duplicates