xxxxxxxxxx
class Solution97
{
//Function to count the number of ways in which frog can reach the top.
static long countWays(int n){
if(n==1) return 1L;
if(n==2) return 2L;
long p1=1L, p2=2L, p3=4L, tmp, mod=(long)(1e9 + 7);
for(int i=4; i<=n; i++) {
tmp = p3;
p3 = (p1 + p2 + p3)%mod;
p1 = p2;
p2 = tmp;
}
return p3%mod;
}
}