{"id":"c0cd3e1d-f3fe-4358-9665-760f624a703c","name":"Climb Stairs","description":"1. You are given a number n, representing the number of stairs in a staircase.\r\n2. You are on the 0th step and are required to climb to the top.\r\n3. In one move, you are allowed to climb 1, 2 or 3 stairs.\r\n4. You are required to print the number of different paths via which you can climb to the top.","inputFormat":"A number n","outputFormat":"A number representing the number of ways to climb the stairs from 0 to top.","constraints":"0 &lt;= n &lt;= 20","sampleCode":{"cpp":{"code":"#include<iostream>\r\nusing namespace std;\r\nint main() {\r\n\r\n return 0;\r\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) throws Exception {\r\n // write your code here\r\n }\r\n\r\n}"},"python":{"code":"def fun(n, dp):\n # write code here\n \n \n return 0\n\n\n# driver code\ndef main():\n n = int(input())\n \n dp = [] * (n+1)\n print(fun(n, dp))\n\nif __name__ == \"__main__\":\n main()"}},"points":10,"difficulty":"easy","sampleInput":"4","sampleOutput":"7","questionVideo":"https://www.youtube.com/embed/A6mOASLl2Dg?end=194","hints":[],"associated":[{"id":"0a1f7c53-f946-4021-9baa-4227406d4055","name":"Dynamic Programming based","slug":"dynamic-programming-based","type":4},{"id":"241ebb9d-5421-473e-b328-856225abdcb7","name":"climb stairs","slug":"climb-stairs","type":4},{"id":"4bd44614-4f20-4b10-b2ac-de323c86dc5a","name":"Dynamic Programming optimise","slug":"dynamic-programming-optimise","type":4},{"id":"b02d3b95-14db-4ded-ab95-e7699a7ecdb6","name":"Climb Stair problem","slug":"climb-stair-problem","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"52d62581-1313-45fb-aaf0-1d72a45f6a50","name":"Dynamic Programming And Greedy For Beginners","slug":"dynamic-programming-and-greedy-for-beginners","type":0},{"id":"e3d771f8-96eb-4ea2-b186-437eacf6ab11","name":"Climb Stairs","slug":"climb-stairs","type":1}],"next":{"id":"f3de766e-1e67-4dce-8cdb-b5b588f1f159","name":"Climb Stairs","type":3,"slug":"climb-stairs"},"prev":{"id":"7149f098-b0a1-4a52-9f67-7ef635a31a2b","name":"Fibonacci (DP)","type":3,"slug":"fibonacci-dp"}}}

# Climb Stairs

1. You are given a number n, representing the number of stairs in a staircase. 2. You are on the 0th step and are required to climb to the top. 3. In one move, you are allowed to climb 1, 2 or 3 stairs. 4. You are required to print the number of different paths via which you can climb to the top.

{"id":"c0cd3e1d-f3fe-4358-9665-760f624a703c","name":"Climb Stairs","description":"1. You are given a number n, representing the number of stairs in a staircase.\r\n2. You are on the 0th step and are required to climb to the top.\r\n3. In one move, you are allowed to climb 1, 2 or 3 stairs.\r\n4. You are required to print the number of different paths via which you can climb to the top.","inputFormat":"A number n","outputFormat":"A number representing the number of ways to climb the stairs from 0 to top.","constraints":"0 &lt;= n &lt;= 20","sampleCode":{"cpp":{"code":"#include<iostream>\r\nusing namespace std;\r\nint main() {\r\n\r\n return 0;\r\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) throws Exception {\r\n // write your code here\r\n }\r\n\r\n}"},"python":{"code":"def fun(n, dp):\n # write code here\n \n \n return 0\n\n\n# driver code\ndef main():\n n = int(input())\n \n dp = [] * (n+1)\n print(fun(n, dp))\n\nif __name__ == \"__main__\":\n main()"}},"points":10,"difficulty":"easy","sampleInput":"4","sampleOutput":"7","questionVideo":"https://www.youtube.com/embed/A6mOASLl2Dg?end=194","hints":[],"associated":[{"id":"0a1f7c53-f946-4021-9baa-4227406d4055","name":"Dynamic Programming based","slug":"dynamic-programming-based","type":4},{"id":"241ebb9d-5421-473e-b328-856225abdcb7","name":"climb stairs","slug":"climb-stairs","type":4},{"id":"4bd44614-4f20-4b10-b2ac-de323c86dc5a","name":"Dynamic Programming optimise","slug":"dynamic-programming-optimise","type":4},{"id":"b02d3b95-14db-4ded-ab95-e7699a7ecdb6","name":"Climb Stair problem","slug":"climb-stair-problem","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"52d62581-1313-45fb-aaf0-1d72a45f6a50","name":"Dynamic Programming And Greedy For Beginners","slug":"dynamic-programming-and-greedy-for-beginners","type":0},{"id":"e3d771f8-96eb-4ea2-b186-437eacf6ab11","name":"Climb Stairs","slug":"climb-stairs","type":1}],"next":{"id":"f3de766e-1e67-4dce-8cdb-b5b588f1f159","name":"Climb Stairs","type":3,"slug":"climb-stairs"},"prev":{"id":"7149f098-b0a1-4a52-9f67-7ef635a31a2b","name":"Fibonacci (DP)","type":3,"slug":"fibonacci-dp"}}}

Editor

# Climb Stairs

easy

1. You are given a number n, representing the number of stairs in a staircase. 2. You are on the 0th step and are required to climb to the top. 3. In one move, you are allowed to climb 1, 2 or 3 stairs. 4. You are required to print the number of different paths via which you can climb to the top.

0 <= n <= 20

## Format

A number n

### Output

A number representing the number of ways to climb the stairs from 0 to top.

## Example

Sample Input

4

### Sample Output

7

Question Video

Discussions

Show Discussion

Related Resources