{"id":"ca10c3a6-1c39-4667-adeb-54c6225aee26","name":"Print 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 printStairPaths function - without changing signature - to print 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\r\n","outputFormat":"Print paths (one path in each line) in order hinted by Sample output\r\n","constraints":"0 &lt;= n &lt;= 10\r\n","sampleCode":{"cpp":{"code":"#include <iostream>\r\nusing namespace std;\r\n\r\nvoid printStairPaths(int n, string psf){\r\n // write your code here\r\n \r\n}\r\n\r\nint main(){\r\n\r\n int n;\r\n cin >> n;\r\n printStairPaths(n, \"\");\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\r\n }\r\n\r\n public static void printStairPaths(int n, String path) {\r\n }\r\n\r\n}"},"python":{"code":"def printStairPaths(ques, asf):\n # write your code here\n \n\nques = int(input())\nprintStairPaths(ques, \"\");"}},"points":10,"difficulty":"easy","sampleInput":"3","sampleOutput":"111\r\n12\r\n21\r\n3","questionVideo":"https://www.youtube.com/embed/JxIoGHzzoW8","hints":[],"associated":[],"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":"0c93f1fa-af96-4e4d-a092-68fadb862202","name":"Print Stair Paths","slug":"print-stair-paths","type":1}],"next":{"id":"018d1ddb-5be1-49ce-a628-7fd0ec2f1b11","name":"Print Stair Paths:","type":3,"slug":"print-stair-paths"},"prev":{"id":"f076b80f-ee54-4ae4-b1f0-8dd840103474","name":"PRINT KPC","type":3,"slug":"print-kpc"}}}

Print 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 printStairPaths function - without changing signature - to print 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":"ca10c3a6-1c39-4667-adeb-54c6225aee26","name":"Print 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 printStairPaths function - without changing signature - to print 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\r\n","outputFormat":"Print paths (one path in each line) in order hinted by Sample output\r\n","constraints":"0 &lt;= n &lt;= 10\r\n","sampleCode":{"cpp":{"code":"#include <iostream>\r\nusing namespace std;\r\n\r\nvoid printStairPaths(int n, string psf){\r\n // write your code here\r\n \r\n}\r\n\r\nint main(){\r\n\r\n int n;\r\n cin >> n;\r\n printStairPaths(n, \"\");\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\r\n }\r\n\r\n public static void printStairPaths(int n, String path) {\r\n }\r\n\r\n}"},"python":{"code":"def printStairPaths(ques, asf):\n # write your code here\n \n\nques = int(input())\nprintStairPaths(ques, \"\");"}},"points":10,"difficulty":"easy","sampleInput":"3","sampleOutput":"111\r\n12\r\n21\r\n3","questionVideo":"https://www.youtube.com/embed/JxIoGHzzoW8","hints":[],"associated":[],"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":"0c93f1fa-af96-4e4d-a092-68fadb862202","name":"Print Stair Paths","slug":"print-stair-paths","type":1}],"next":{"id":"018d1ddb-5be1-49ce-a628-7fd0ec2f1b11","name":"Print Stair Paths:","type":3,"slug":"print-stair-paths"},"prev":{"id":"f076b80f-ee54-4ae4-b1f0-8dd840103474","name":"PRINT KPC","type":3,"slug":"print-kpc"}}}
plane

Editor


Loading...

Print 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 printStairPaths function - without changing signature - to print 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

Print paths (one path in each line) in order hinted by 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