{"id":"3952eb70-35da-4fc5-bd6c-8536facd3b8d","name":"Get Stair Paths","description":"1. You are given a number n representing number of stairs in a staircase.\r\n2. You are standing at the bottom of staircase. You are allowed to climb 1 step, 2 steps or 3 steps in one move.\r\n3. Complete the body of getStairPaths function - without changing signature - to get the list of all paths that can be used to climb the staircase up.\r\nUse sample input and output to take idea about output.\r\n\r\nNote -> The online judge can't force you to write the function recursively but that is what the spirit of question is. Write recursive and not iterative logic. The purpose of the question is to aid learning recursion and not test you.","inputFormat":"A number n","outputFormat":"Contents of the arraylist containing paths as shown in sample output","constraints":"0 &lt;= n &lt;= 10","sampleCode":{"cpp":{"code":"#include<iostream>\n#include<vector>\n#include<string>\nusing namespace std;\n\nvector<string> get_stair_paths(int n){\n //Write your code here\n}\n\nint main(){\n int n;\n cin >> n;\n vector<string> ans = get_stair_paths(n);\n int cnt = 0;\n\n cout << '[';\n for (string str : ans){\n if (cnt != ans.size() - 1)\n cout << str << \", \";\n else\n cout << str;\n cnt++;\n }\n cout << ']';\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\r\n }\r\n\r\n public static ArrayList<String> getStairPaths(int n) {\r\n return null;\r\n }\r\n\r\n}"},"python":{"code":"n = int(input())\n\ndef get_stair_paths(n):\n #Write your code here\n \nans = get_stair_paths(n)\n\nprint(\"[\"+', '.join(ans) + \"]\")"}},"points":10,"difficulty":"easy","sampleInput":"3","sampleOutput":"[111, 12, 21, 3]","questionVideo":"https://www.youtube.com/embed/W6cT68K7Hls","hints":[],"associated":[{"id":"b07afa4b-f6aa-4085-aa3f-d6c80e76087a","name":"(Get Stair paths)What is the time complexity of this question ?","slug":"get-stair-paths-what-is-the-time-complexity-of-this-question","type":4},{"id":"cc3b5d9b-a13a-4d27-b4e8-5726992e7cb3","name":"(Get Stair paths) How many recursive calls will be made ?","slug":"get-stair-paths-how-many-recursive-calls-will-be-made","type":4},{"id":"e6d4b4fd-b131-4462-a6dd-e55959ed218e","name":"(Get Stair paths)What is the space complexity of this question ?","slug":"get-stair-paths-what-is-the-space-complexity-of-this-question","type":4},{"id":"fa902246-3d04-44f4-9cf6-886c18e09235","name":"(Get Stair paths) If n = 3 then all the paths will be ?","slug":"get-stair-paths-if-n-3-then-all-the-paths-will-be","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":"d341a7c9-1269-409c-b851-0bb512289544","name":"Recursion And Backtracking For Beginners","slug":"recursion-and-backtracking-for-beginners","type":0},{"id":"17c0ada5-3276-4f47-88ea-8fd7e208b73d","name":"Get Stair Paths","slug":"get-stair-paths","type":1}],"next":{"id":"4a407334-569a-4214-b68a-af7de9927c4a","name":"Get Stair Paths","type":3,"slug":"get-stair-paths"},"prev":{"id":"c32c9630-ef86-4440-ba9e-9c3488c293f3","name":"Get Kpc","type":3,"slug":"get-kpc"}}}

Get Stair Paths

1. You are given a number n representing number of stairs in a staircase. 2. You are standing at the bottom of staircase. You are allowed to climb 1 step, 2 steps or 3 steps in one move. 3. Complete the body of getStairPaths function - without changing signature - to get the list of all paths that can be used to climb the staircase up. Use sample input and output to take idea about output. Note -> The online judge can't force you to write the function recursively but that is what the spirit of question is. Write recursive and not iterative logic. The purpose of the question is to aid learning recursion and not test you.

{"id":"3952eb70-35da-4fc5-bd6c-8536facd3b8d","name":"Get Stair Paths","description":"1. You are given a number n representing number of stairs in a staircase.\r\n2. You are standing at the bottom of staircase. You are allowed to climb 1 step, 2 steps or 3 steps in one move.\r\n3. Complete the body of getStairPaths function - without changing signature - to get the list of all paths that can be used to climb the staircase up.\r\nUse sample input and output to take idea about output.\r\n\r\nNote -> The online judge can't force you to write the function recursively but that is what the spirit of question is. Write recursive and not iterative logic. The purpose of the question is to aid learning recursion and not test you.","inputFormat":"A number n","outputFormat":"Contents of the arraylist containing paths as shown in sample output","constraints":"0 &lt;= n &lt;= 10","sampleCode":{"cpp":{"code":"#include<iostream>\n#include<vector>\n#include<string>\nusing namespace std;\n\nvector<string> get_stair_paths(int n){\n //Write your code here\n}\n\nint main(){\n int n;\n cin >> n;\n vector<string> ans = get_stair_paths(n);\n int cnt = 0;\n\n cout << '[';\n for (string str : ans){\n if (cnt != ans.size() - 1)\n cout << str << \", \";\n else\n cout << str;\n cnt++;\n }\n cout << ']';\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\r\n }\r\n\r\n public static ArrayList<String> getStairPaths(int n) {\r\n return null;\r\n }\r\n\r\n}"},"python":{"code":"n = int(input())\n\ndef get_stair_paths(n):\n #Write your code here\n \nans = get_stair_paths(n)\n\nprint(\"[\"+', '.join(ans) + \"]\")"}},"points":10,"difficulty":"easy","sampleInput":"3","sampleOutput":"[111, 12, 21, 3]","questionVideo":"https://www.youtube.com/embed/W6cT68K7Hls","hints":[],"associated":[{"id":"b07afa4b-f6aa-4085-aa3f-d6c80e76087a","name":"(Get Stair paths)What is the time complexity of this question ?","slug":"get-stair-paths-what-is-the-time-complexity-of-this-question","type":4},{"id":"cc3b5d9b-a13a-4d27-b4e8-5726992e7cb3","name":"(Get Stair paths) How many recursive calls will be made ?","slug":"get-stair-paths-how-many-recursive-calls-will-be-made","type":4},{"id":"e6d4b4fd-b131-4462-a6dd-e55959ed218e","name":"(Get Stair paths)What is the space complexity of this question ?","slug":"get-stair-paths-what-is-the-space-complexity-of-this-question","type":4},{"id":"fa902246-3d04-44f4-9cf6-886c18e09235","name":"(Get Stair paths) If n = 3 then all the paths will be ?","slug":"get-stair-paths-if-n-3-then-all-the-paths-will-be","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":"d341a7c9-1269-409c-b851-0bb512289544","name":"Recursion And Backtracking For Beginners","slug":"recursion-and-backtracking-for-beginners","type":0},{"id":"17c0ada5-3276-4f47-88ea-8fd7e208b73d","name":"Get Stair Paths","slug":"get-stair-paths","type":1}],"next":{"id":"4a407334-569a-4214-b68a-af7de9927c4a","name":"Get Stair Paths","type":3,"slug":"get-stair-paths"},"prev":{"id":"c32c9630-ef86-4440-ba9e-9c3488c293f3","name":"Get Kpc","type":3,"slug":"get-kpc"}}}
plane

Editor


Loading...

Get Stair Paths

easy

1. You are given a number n representing number of stairs in a staircase. 2. You are standing at the bottom of staircase. You are allowed to climb 1 step, 2 steps or 3 steps in one move. 3. Complete the body of getStairPaths function - without changing signature - to get the list of all paths that can be used to climb the staircase up. Use sample input and output to take idea about output. Note -> The online judge can't force you to write the function recursively but that is what the spirit of question is. Write recursive and not iterative logic. The purpose of the question is to aid learning recursion and not test you.

Constraints

0 <= n <= 10

Format

Input

A number n

Output

Contents of the arraylist containing paths as shown in sample output

Example

Sample Input

3

Sample Output

[111, 12, 21, 3]

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode