# Chapter 9: Dynamic Programming

* Every dynamic-programming solution involves a grid.
* The values in the cells are usually what you’re trying to optimize. For the knapsack problem, the values were the value of the goods.
* Each cell is a subproblem, so think about how you can divide your problem into subproblems. That will help you figure out what the axes are.
* Dynamic programming is useful when you’re trying to optimize something given a constraint.
* You can use dynamic programming when the problem can be broken into discrete subproblems.
* Every dynamic-programming solution involves a grid.
* The values in the cells are usually what you’re trying to optimize.
* Each cell is a subproblem, so think about how you can divide your problem into subproblems.
* There’s no single formula for calculating a dynamic-programming solution.

Implementation：

* git diff
* Biologists use the longest common subsequence to find similarities in DNA strands


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://haroldyin.gitbook.io/grokking-algorithm/chapter-9-dynamic-programming.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
