This article was originally published in The Language Sparrow Archive
The title
Leetcode-cn.com/problems/cl…
Flow chart, debug code
Github.com/blueju/leet… /
First attempt
The classic Fibonacci sequence, the first attempt, of course, was recursion
Wrong:
- Recursion tends to cause the memory occupied by the function at the previous level to be unable to be released, and then the stack will burst
Second attempt
No errors, passed the test case
conclusion
Like the first few cases are our own brain to calculate, calculate a few more, find a rule, like junior high school/high school mathematics/public line test of the graph.