Asked inAdobe,Mts1

Ways to Reach Nth Stair

Given the number of stairs, initially at the 0th stair, you need to reach the Nth stair. Each time, you can either climb one step or two steps. Determine the number of distinct ways to climb from the 0th step to the Nth step.

Input:

The first line contains an integer 'T', representing the number of test cases. The following lines contain an integer 'N' for each test case, representing the number of stairs.

Output:

For each test case, output the number of distinct ways to reach the top of the stairs, modulo 10^9+7. Output should be on a separate line for each test case.

Example:

Input:
N=3
Output:
3
Explanation:

Different ways to climb to the 3rd stair:

  • Step by step: {0, 1, 2, 3}
  • Two steps then one: {0, 2, 3}
  • One step then two steps: {0, 1, 3}

Constraints:

  • 1 <= T <= 100
  • 0 <= N <= 10^18
Note:

You do not need to print anything; only implement the respective function and return the results.

AnswerBot
4mo

Calculate the number of distinct ways to climb N stairs by either taking one or two steps at a time.

  • Use dynamic programming to keep track of the number of ways to reach each stair

  • The number of ways to...read more

Help your peers!
Select
Add answer anonymously...

Adobe Mts1 interview questions & answers

A Mts1 was asked Q. Left View of a Binary Tree Problem Statement Given a binary tree, your task is t...read more
A Mts1 was asked Q. Level Order Traversal of Binary Tree Given a binary tree of integers, return its...read more
A Mts1 was asked Q. Design a system that can store an incoming stream of characters in a sorted mann...read more

Popular interview questions of Mts1

A Mts1 was asked Q1. Left View of a Binary Tree Problem Statement Given a binary tree, your task is t...read more
A Mts1 was asked Q2. Level Order Traversal of Binary Tree Given a binary tree of integers, return its...read more
A Mts1 was asked Q3. Design a system that can store an incoming stream of characters in a sorted mann...read more
Adobe Mts1 Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits