← Whiteboard questions

Pattern

2-D DP

Use a two-dimensional table when the state needs two numbers, such as a position in each of two strings, or a row and a column. Each cell depends on a few neighbours. The cost is usually the table size, and you can often keep only one or two rows.

2-D DP interview questions and solutions