Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Count number of hops(Amazon interview Question) #1077

Open
Manish4Kumar opened this issue Sep 16, 2023 · 1 comment
Open

Count number of hops(Amazon interview Question) #1077

Manish4Kumar opened this issue Sep 16, 2023 · 1 comment

Comments

@Manish4Kumar
Copy link

class Solution
{
public:
//Function to count the number of ways in which frog can reach the top.
long long countWays(int n)
{
long long dp[n];
long long mod=1e9+7;
dp[0] = dp[1] = 1;
dp[2] = 2;
for (int i = 3; i <= n; i++){
dp[i] = ((dp[i - 1] % mod) + (dp[i - 2]%mod) + (dp[i - 3]%mod))%mod;
}
return dp[n]%mod;
}
};

@Manish4Kumar
Copy link
Author

pls merge my pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant