Count Ways to Reach the N-th Stair Problem Statement
You are provided with a number of stairs, and initially, you are located at the 0th stair. You need to reach the Nth stair, and you can climb one or two steps at a time. Your task is to determine the number of distinct ways to climb from the 0th to the Nth stair.
Input:
The first line contains an integer 'T', denoting the number of test cases. For each test case, there is a single integer 'N' which represents the number of stairs.
Output:
For each test case, print the number of distinct ways to reach the Nth stair, modulo 10^9+7. The result for each test case should be on a new line.
Example:
Input:
N=3
Output:
The number of distinct ways to reach the 3rd stair is 3, considering all possible sequences of climbing as shown in the example.
Constraints:
1 <= T <= 100
0 <= N <= 10^18
Note:
You are not required to print anything yourself; the output handling is managed by the system.
AnswerBot
1y
The task is to find the number of distinct ways to climb from the 0th step to the Nth step, where each time you can climb either one step or two steps.
Use dynamic programming to solve this problem
Crea...read more
Help your peers!
Add answer anonymously...
Top Paytm Full Stack Developer interview questions & answers
Popular interview questions of Full Stack Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app