Offer 10- II. 青蛙跳台阶问题(numWays)
1. python
class Solution:
def numWays(self, n: int) -> int:
a,b = 1,1
for _ in range(n):
a ,b = b,a+b
return a % 1000000007
2. Java
class Solution {
public int numWays(int n) {
int a =1,b =1,sum;
for(int i =0;i<n;i++){
sum = (a+b)%1000000007;
a=b;
b=sum;
}
return a;
}
}