Question: https://oj.leetcode.com/problems/climbing-stairs/
Question Name: Climbing Stairs
1 2 3 4 5 6 7 8 9 10 11 12 | class Solution: # @param n, an integer # @return an integer def climbStairs(self, n): ''' The number of distinct ways to take n steps is the Fibonacci number. http://en.wikipedia.org/wiki/Fibonacci_number ''' steps = [1, 1] while len(steps) < n + 1: steps.append(steps[-1] + steps[-2]) return steps[n] |