Skip to content

Dynamic Programming Notes

Carl Liu edited this page Aug 4, 2020 · 13 revisions

Categorization

Counting

  • How many ways to go to the left bottom corner
  • How many ways to find k elements to get to a sum
  • How many ways to permutate for a valid answer

Maximum/Minimum

True/False

Type

Coordinate Based

Overview

  • Usually given an array/sequence or grid/matrix as your input
  • Need to find a subsequence/vector/path for
    • maximizing/minimizing a certain property
    • counting
    • true/false
  • State is represented by dp[i] and dp[i][j], which are the most optimal cases for a[i] or a[i][j]
  • Initalization is usually dp[0] with a[0]

Examples

Sequence-Based

Overview

Partition-based