Teach you a trick, dynamic programming thinking

dynamic programming

What is Dynamic Programming?

Dynamic programming is also a method/thought of algorithm design. It decomposes a problem into overlapping sub-problems, and solves the original problem by repeatedly solving the sub-problems.

base case

scene one

Fibonacci sequence

The current number is equal to the sum of the previous two numbers.

insert image description here

Define subproblems:f(n) = f(n-1) + f(n-2)

Original Link: Vegetable Garden Front End

Guess you like

Origin blog.csdn.net/qq2603375880/article/details/131772196