File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
2+ "nbformat" : 4 ,
3+ "nbformat_minor" : 2 ,
4+ "metadata" : {},
25 "cells" : [
36 {
4- "cell_type" : " code" ,
5- "execution_count" : null ,
67 "metadata" : {},
7- "outputs" : [],
88 "source" : [
9- " dp = [0 for _ in range(10000000)]\n " ,
10- " \n " ,
11- " \n " ,
129 " def fib(n):\n " ,
13- " if n == 0:\n " ,
14- " return dp[0]\n " ,
15- " if n == 1:\n " ,
16- " return dp[1]\n " ,
17- " dp[0] = 0\n " ,
18- " dp[1] = 1\n " ,
10+ " dp = [0, 1]\n " ,
11+ " if n == 0 or n == 1:\n " ,
12+ " return dp[n]\n " ,
1913 " for i in range(2, n + 1):\n " ,
20- " dp[i] = dp[i - 1] + dp[i - 2]\n " ,
14+ " dp.append( dp[i - 1] + dp[i - 2]) \n " ,
2115 " return dp[n]\n " ,
2216 " \n " ,
2317 " \n " ,
2418 " print(fib(100))"
25- ]
19+ ],
20+ "cell_type" : " code" ,
21+ "outputs" : [],
22+ "execution_count" : null
2623 }
27- ],
28- "metadata" : {},
29- "nbformat" : 4 ,
30- "nbformat_minor" : 2
24+ ]
3125}
You can’t perform that action at this time.
0 commit comments