← Whiteboard questions

Pattern

1-D DP

Use dynamic programming when a big answer is built from answers to smaller versions of the same problem, and those smaller answers repeat. Say what one table cell means, write how a cell depends on earlier cells, then fill the table in order. One dimension often needs only O(n) time.

1-D DP interview questions and solutions