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 steps. You are supposed to return the number of distinct ways in which you can climb from the 0th step to Nth step. Example...

read more
CodingNinjas
author
2y
Approach (Using DP) : We reach “currStep” step in taking one step or two steps:We can take the one-step from (currStep-1)th step or,We can take the two steps from (currStep-2)th step.So the total...
see more
CodingNinjas
author
2y
Brute ForceOne basic approach is to explore all possible steps which can be climbed with either taking one step or two steps. So at every step, we have two options to climb the stairs either we can cl...
see more
CodingNinjas
author
2y
Using MemoizationIn the previous approach, we were naively calculating the results for every step. So there were lots of redundant calls because if we look at the recursion tree, then there are only ‘...
see more
Add answer anonymously...
Infosys System Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

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

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter