2-D Dynamic Programming

Last updated

What is 2-D Dynamic Programming?

Two-dimensional DP extends the same ideas to problems where the state depends on two variables simultaneously, typically two indices into two sequences or two dimensions of a grid. The table is now a matrix, and each cell is filled based on cells above it, to its left, or diagonally adjacent. The problems here include string comparison (edit distance, longest common subsequence), grid path counting, and interval DP where you think about ranges rather than prefixes. These problems tend to be harder to set up than 1-D DP, but once you identify the state and the transition, the code follows directly from the recurrence.

Free resources to learn 2-D Dynamic Programming

More in stage 17: D Dynamic Programming

2-D Dynamic Programming: common questions

Can I learn 2-D Dynamic Programming in Hindi?

This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain 2-D Dynamic Programming in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.

Is this 2-D Dynamic Programming tutorial for beginners?

It is lesson 103 of 137 in the free LeetCode roadmap, in stage 17, D Dynamic Programming. If you are new to LeetCode, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.

Still confused? Ask me