{"id":"01ccdeb7-ad40-4722-9c4e-b5975e0dcca8","name":"Print Maze Paths","description":"1. You are given a number n and a number m representing number of rows and columns in a maze.\r\n2. You are standing in the top-left corner and have to reach the bottom-right corner. Only two moves are allowed 'h' (1-step horizontal) and 'v' (1-step vertical).\r\n3. Complete the body of pri tMazePath function - without changing signature - to print the list of all paths that can be used to move from top-left to bottom-right.\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\nA number m","outputFormat":"Print paths (one path in each line) in order hinted by Sample output","constraints":"0 &lt;= n &lt;= 10\r\n0 &lt;= m &lt;= 10","sampleCode":{"cpp":{"code":"#include <iostream>\r\nusing namespace std;\r\n\r\nvoid printMazePaths(int sr, int sc, int dr, int dc, string psf){\r\n // write your code here\r\n \r\n}\r\n\r\nint main(){\r\n int n;\r\n int m;\r\n cin >> n >> m;\r\n printMazePaths(0, 0, n - 1, m - 1, \"\");\r\n}"},"java":{"code":"import java.io.*;\r\n\timport java.util.*;\r\n\r\n\tpublic class Main {\r\n\r\n\t public static void main(String[] args) throws Exception {\r\n\r\n\t }\r\n\r\n\t // sr - source row\r\n\t // sc - source column\r\n\t // dr - destination row\r\n\t // dc - destination column\r\n\t public static void printMazePaths(int sr, int sc, int dr, int dc, String psf) {\r\n\t \r\n\t }\r\n\r\n\t}"},"python":{"code":"def printMazePaths(sr, sc, dr, dc, asf):\n # write your code here\n \n\nn = int(input())\nm = int(input())\n\nprintMazePaths(0, 0, n - 1, m - 1, \"\")"}},"points":10,"difficulty":"easy","sampleInput":"2\r\n2","sampleOutput":"hv\r\nvh","questionVideo":"https://www.youtube.com/embed/TcCyI-eJMmY","hints":[],"associated":[{"id":"5bf3a467-322b-4ceb-b3ef-9e9255b59f82","name":"(Print Maze Paths) What are the prerequisites for this question?","slug":"print-maze-paths-what-are-the-prerequisites-for-this-question","type":4},{"id":"b012ace4-10e8-40da-9226-0db2d13e0d76","name":"(Print Maze Paths) What will be the time complexity?","slug":"print-maze-paths-what-will-be-the-time-complexity","type":4},{"id":"b3d1c4b5-e545-4ac8-ab8d-61b9ad28ae1e","name":"(Print Maze Paths) What did we use in getMazePath?","slug":"print-maze-paths-what-did-we-use-in-getmazepath","type":4},{"id":"e7627270-5714-4243-9632-0a526ca3c706","name":"(Print Maze Paths)What type of recursion are we using?","slug":"print-maze-paths-what-type-of-recursion-are-we-using","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":"06bee522-3b40-4d86-8381-d5490948e5ea","name":"Print Maze Paths","slug":"print-maze-paths","type":1}],"next":{"id":"9180cacf-38c1-47da-a9bb-07a96fa9d8ba","name":"Print Maze Path","type":3,"slug":"print-maze-path"},"prev":{"id":"018d1ddb-5be1-49ce-a628-7fd0ec2f1b11","name":"Print Stair Paths:","type":3,"slug":"print-stair-paths"}}}

Print Maze Paths

1. You are given a number n and a number m representing number of rows and columns in a maze. 2. You are standing in the top-left corner and have to reach the bottom-right corner. Only two moves are allowed 'h' (1-step horizontal) and 'v' (1-step vertical). 3. Complete the body of pri tMazePath function - without changing signature - to print the list of all paths that can be used to move from top-left to bottom-right. 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":"01ccdeb7-ad40-4722-9c4e-b5975e0dcca8","name":"Print Maze Paths","description":"1. You are given a number n and a number m representing number of rows and columns in a maze.\r\n2. You are standing in the top-left corner and have to reach the bottom-right corner. Only two moves are allowed 'h' (1-step horizontal) and 'v' (1-step vertical).\r\n3. Complete the body of pri tMazePath function - without changing signature - to print the list of all paths that can be used to move from top-left to bottom-right.\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\nA number m","outputFormat":"Print paths (one path in each line) in order hinted by Sample output","constraints":"0 &lt;= n &lt;= 10\r\n0 &lt;= m &lt;= 10","sampleCode":{"cpp":{"code":"#include <iostream>\r\nusing namespace std;\r\n\r\nvoid printMazePaths(int sr, int sc, int dr, int dc, string psf){\r\n // write your code here\r\n \r\n}\r\n\r\nint main(){\r\n int n;\r\n int m;\r\n cin >> n >> m;\r\n printMazePaths(0, 0, n - 1, m - 1, \"\");\r\n}"},"java":{"code":"import java.io.*;\r\n\timport java.util.*;\r\n\r\n\tpublic class Main {\r\n\r\n\t public static void main(String[] args) throws Exception {\r\n\r\n\t }\r\n\r\n\t // sr - source row\r\n\t // sc - source column\r\n\t // dr - destination row\r\n\t // dc - destination column\r\n\t public static void printMazePaths(int sr, int sc, int dr, int dc, String psf) {\r\n\t \r\n\t }\r\n\r\n\t}"},"python":{"code":"def printMazePaths(sr, sc, dr, dc, asf):\n # write your code here\n \n\nn = int(input())\nm = int(input())\n\nprintMazePaths(0, 0, n - 1, m - 1, \"\")"}},"points":10,"difficulty":"easy","sampleInput":"2\r\n2","sampleOutput":"hv\r\nvh","questionVideo":"https://www.youtube.com/embed/TcCyI-eJMmY","hints":[],"associated":[{"id":"5bf3a467-322b-4ceb-b3ef-9e9255b59f82","name":"(Print Maze Paths) What are the prerequisites for this question?","slug":"print-maze-paths-what-are-the-prerequisites-for-this-question","type":4},{"id":"b012ace4-10e8-40da-9226-0db2d13e0d76","name":"(Print Maze Paths) What will be the time complexity?","slug":"print-maze-paths-what-will-be-the-time-complexity","type":4},{"id":"b3d1c4b5-e545-4ac8-ab8d-61b9ad28ae1e","name":"(Print Maze Paths) What did we use in getMazePath?","slug":"print-maze-paths-what-did-we-use-in-getmazepath","type":4},{"id":"e7627270-5714-4243-9632-0a526ca3c706","name":"(Print Maze Paths)What type of recursion are we using?","slug":"print-maze-paths-what-type-of-recursion-are-we-using","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":"06bee522-3b40-4d86-8381-d5490948e5ea","name":"Print Maze Paths","slug":"print-maze-paths","type":1}],"next":{"id":"9180cacf-38c1-47da-a9bb-07a96fa9d8ba","name":"Print Maze Path","type":3,"slug":"print-maze-path"},"prev":{"id":"018d1ddb-5be1-49ce-a628-7fd0ec2f1b11","name":"Print Stair Paths:","type":3,"slug":"print-stair-paths"}}}
plane

Editor


Loading...

Print Maze Paths

easy

1. You are given a number n and a number m representing number of rows and columns in a maze. 2. You are standing in the top-left corner and have to reach the bottom-right corner. Only two moves are allowed 'h' (1-step horizontal) and 'v' (1-step vertical). 3. Complete the body of pri tMazePath function - without changing signature - to print the list of all paths that can be used to move from top-left to bottom-right. 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 0 <= m <= 10

Format

Input

A number n A number m

Output

Print paths (one path in each line) in order hinted by Sample output

Example

Sample Input

2 2

Sample Output

hv vh

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode