O (n) - Linear. 透過for loop 計算費氏數列,時間複雜度為 O(n). copy. 1// [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...] 2function fib(n) {. 3 const arr = [0, 1];.
確定! 回上一頁