#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2020/5/21 下午11:12
# @Author : Yuxiaoxue# @Site :
# @File : question3.py
# @Software: PyCharm
'''
题目描述:
一只青蛙一次可以跳上1级台阶,也可以跳上2级……它也可以跳上n级。求该青蛙跳上一个n级的台阶总共有多少种跳法。
'''
'''
解题思路:
'''
def jumpFloorII(number):
A = []
A.append(1)
#print(A[0])
for i in range(1,number):
sumi = 2*A[i-1]
A.append(sumi)
#print(A[i])
return A[number-1]
self = ''
sumi = jumpFloorII(4)
print(sumi)
'''
下面是最终提交的代码:
# -*- coding:utf-8 -*-
class Solution:
def jumpFloorII(self,number):
if number == 0:
return 0
A = []
A.append(1)
for i in range(1,number):
#A[i] = 2*A[i-1]
sumi = 2*A[i-1]
A.append(sumi)
return A[number-1]
'''
网友评论