LeetCode Note Java 00509:Fibonacci Number
經典題:費式數列。
題目
Fibonacci Number Easy
The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,
1 | F(0) = 0, F(1) = 1 |
Given n, calculate F(n).
我的解法
經典題,就遞迴法或 Dynamic Programming 實作。
1 | class Solution { |
1 | class Solution { |
Dynamic Programming 的效能會比遞迴法好滿多。