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
4mo
The problem involves determining the number of distinct ways to climb from the 0th to the Nth stair by climbing one or two steps at a time.
Use dynamic programming to solve this problem efficiently.
Def...read more
Boggula Venkata Ajith Reddy
6mo
You have been given a number of stairs. Initially, you are at the 0th stair, and you need to reach the Nth stair. Each time you can either climb one step or two steps. You are supposed to return the n...read more
Boggula Venkata Ajith Reddy
6mo
Count Ways To Reach The N-th Stairs You have been given a number of stairs. Initially, you are at the 0th stair, and you need to reach the Nth stair. Each time you can either climb one step or two ste...read more
Anonymous
2y
(currStep -1)We can take the one-step from (currStep-1)
Comment deleted
Add answer anonymously...
Infosys System Engineer interview questions & answers
A System Engineer was asked 2w agoQ. What is method overriding?
A System Engineer was asked 2w agoQ. What is the process for reversing a number?
A System Engineer was asked 2w agoQ. What are the details of Object-Oriented Programming (OOP) concepts?
Popular interview questions of System Engineer
A System Engineer was asked 2w agoQ1. What is the process for reversing a number?
A System Engineer was asked 2w agoQ2. What is method overriding?
A System Engineer was asked 2w agoQ3. What are the details of Object-Oriented Programming (OOP) concepts?
Top HR questions asked in Infosys System Engineer
A System Engineer was asked 2mo agoQ1. Explain your project.
A System Engineer was asked 3mo agoQ2. Explain your final semester project.
A System Engineer was asked 3mo agoQ3. What was your involvement in your college project?
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

