class Solution {
public int numWays(int n) {
if(n < 2){
return 1;
}
if(n == 2){
return n;
}
int a = 1, b = 2, sum = 2;
for(int i = 2; i < n; i++){
sum = (a + b) % 1000000007;
a = b;
b = sum;
}
return sum;
}
}
评论