• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
April 07, 2024 |780 Views
PROBLEM OF THE DAY : 06/04/2024 | Count ways to N'th Stair
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Yash Dwivedi. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of DP but also build up problem-solving skills.

In this problem, we are given, there are n stairs, and a person standing at the bottom wants to reach the top. The person can climb either 1 stair or 2 stairs at a time. Count the number of ways, the person can reach the top (order does not matter).

Example :

Input:
n = 4
Output: 
3
Explanation: 
You can reach 4th stair in 3 ways. 3 possible ways are:
1, 1, 1, 1
1, 1, 2
2, 2
Here, note that {1, 1, 2}, {1, 2, 1} and {2, 1, 1} are considered same as their order does not matter. 

Give the problem a try before going through the video. All the best!!!
Problem Link: https://www.geeksforgeeks.org/problems/count-ways-to-nth-stairorder-does-not-matter1322/1
Solution IDE Link: https://ide.geeksforgeeks.org/online-cpp14-compiler/2fd77a44-ecda-43e5-8eef-856f5a1cded5