Skip to content
playdsa
Preferences

Make yourself comfortable.

Saved on this browser. Your device’s reduced-motion preference is always respected.

Theme
Advanced settings
Back to syllabus

Two-Dimensional DP

5 chapters · 12 challenges · The Echo Matrix

Understand the idea, practise through play, then prove it in code. Choose your next quest below.

Visual introduction to this topic
Start here · 3 minute mental model

What is two-dimensional dynamic programming?

Two-dimensional DP stores answers identified by two changing coordinates, such as row and column, two string positions, or the ends of an interval.

Think of mapping a tiled dungeon. The best answer for one tile depends on already mapped neighbors. Record each tile once, then let later tiles build on it.

The dependency arrows decide the only safe order for filling the table.

Name both axes

Rows and columns must each represent a real part of the subproblem.

Draw dependencies

A state may read left, up, diagonal, smaller intervals, or another layer.

Set boundary states

Empty prefixes and outer rows often remove special cases from the transition.

What you will learn firstPaths Across the Matrix

Combine answers from above and left

Begin the guided lesson

Your chapter route

Paths Across the Matrix

Continue
Source reviewed

Built from authoritative material

This track is checked against the sources below. Visual traces still carry their own complete or guided coverage label, so unfinished explanations are not presented as complete executions.

Help shape PlayDSA

Something confusing, broken, or missing? Leave a quick note without leaving your lesson.

Please leave out passwords, payment details and other private information.

Page included: /

Sign in to save feedback here, or send it with your email app. Your draft stays here while you sign in.

Open email instead