{"id":"cb31533a-93ec-4ba4-ab89-8790a5ebe959","name":"Get Maze Path With Jumps","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. \r\n3. In a single move you are allowed to jump 1 or more steps horizontally (as h1, h2, .. ), or 1 or more steps vertically (as v1, v2, ..) or 1 or more steps diagonally (as d1, d2, ..). \r\n4. Complete the body of getMazePath function - without changing signature - to get 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":"Contents of the arraylist containing paths as shown in sample output","constraints":"0 &lt;= n &lt;= 10\r\n0 &lt;= m &lt;= 10","sampleCode":{"cpp":{"code":"#include<iostream>\n#include<vector>\n#include<string>\n\nusing namespace std;\n\nvector<string> get_maze_paths(int sr, int sc, int dr, int dc) {\n //Write your code here\n }\n \nvoid display(vector<string>& arr){\n cout << \"[\";\n for(int i = 0;i < arr.size();i++){\n cout << arr[i];\n if(i < arr.size() -1) cout << \", \";\n }\n \n cout << \"]\"<<endl;\n}\n\n\nint main() {\n int n,m; cin >> n >> m;\n vector<string> ans = get_maze_paths(0,0,n-1,m-1);\n display(ans);\n\n return 0;\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 // sr - source row\r\n // sc - source column\r\n // dr - destination row\r\n // dc - destination column\r\n public static ArrayList<String> getMazePaths(int sr, int sc, int dr, int dc) {\r\n return null;\r\n }\r\n\r\n}"},"python":{"code":"n = int(input())\nm = int(input())\n\ndef get_maze_paths(sr, sc, dr, dc):\n #Write your code here\n \nans = get_maze_paths(0, 0, n-1, m-1)\n\nprint(\"[\"+', '.join(ans) + \"]\")"}},"points":10,"difficulty":"easy","sampleInput":"2\r\n2","sampleOutput":"[h1v1, v1h1, d1]","questionVideo":"https://www.youtube.com/embed/F6T3tD8Pw20","hints":[],"associated":[{"id":"18d5717c-849b-4cfb-95ed-fb58e7f8b3c7","name":"(Get Maze Paths with jumps) How many functions calls will be required for recursive solution of this question?","slug":"get-maze-paths-with-jumps-how-many-functions-calls-will-be-required-for-recursive-solution-of-this-question","type":4},{"id":"61647f16-07a7-4378-a335-542ee357486a","name":"(Get Maze Paths with jumps) What will be your output for destination row = 2 and destination column = 3","slug":"get-maze-paths-with-jumps-what-will-be-your-output-for-destination-row-2-and-destination-column-3","type":4},{"id":"66c6d83e-d489-4f5d-bbcc-878a635fdb82","name":"(Get Maze Paths with jumps) What will be the base conditions if dr and dc are destination row and destination columns ans cr and cc are current row and current columns for proactive call.","slug":"get-maze-paths-with-jumps-what-will-be-the-base-conditions-if-dr-and-dc-are-destination-row-and-destination-columns-ans-cr-and-cc-are-current-row-and-current-columns-for-proactive-call","type":4},{"id":"baea3333-3945-4162-b883-219435982177","name":"(Get Maze Paths with jumps) What is space and time complexity of the code?","slug":"get-maze-paths-with-jumps-what-is-space-and-time-complexity-of-the-code","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":"a6a44362-0973-4003-a556-b1225e979e75","name":"Get Maze Path With Jumps","slug":"get-maze-path-with-jumps","type":1}],"next":{"id":"bdaf583e-a53c-49a6-81f2-52fc05ce0352","name":"Get Maze Path With Jumps","type":3,"slug":"get-maze-path-with-jumps"},"prev":{"id":"faf3f244-a011-4897-ba1f-2189f3051989","name":"Get Maze Paths","type":3,"slug":"get-maze-paths"}}}

Get Maze Path With Jumps

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. 3. In a single move you are allowed to jump 1 or more steps horizontally (as h1, h2, .. ), or 1 or more steps vertically (as v1, v2, ..) or 1 or more steps diagonally (as d1, d2, ..). 4. Complete the body of getMazePath function - without changing signature - to get 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":"cb31533a-93ec-4ba4-ab89-8790a5ebe959","name":"Get Maze Path With Jumps","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. \r\n3. In a single move you are allowed to jump 1 or more steps horizontally (as h1, h2, .. ), or 1 or more steps vertically (as v1, v2, ..) or 1 or more steps diagonally (as d1, d2, ..). \r\n4. Complete the body of getMazePath function - without changing signature - to get 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":"Contents of the arraylist containing paths as shown in sample output","constraints":"0 &lt;= n &lt;= 10\r\n0 &lt;= m &lt;= 10","sampleCode":{"cpp":{"code":"#include<iostream>\n#include<vector>\n#include<string>\n\nusing namespace std;\n\nvector<string> get_maze_paths(int sr, int sc, int dr, int dc) {\n //Write your code here\n }\n \nvoid display(vector<string>& arr){\n cout << \"[\";\n for(int i = 0;i < arr.size();i++){\n cout << arr[i];\n if(i < arr.size() -1) cout << \", \";\n }\n \n cout << \"]\"<<endl;\n}\n\n\nint main() {\n int n,m; cin >> n >> m;\n vector<string> ans = get_maze_paths(0,0,n-1,m-1);\n display(ans);\n\n return 0;\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 // sr - source row\r\n // sc - source column\r\n // dr - destination row\r\n // dc - destination column\r\n public static ArrayList<String> getMazePaths(int sr, int sc, int dr, int dc) {\r\n return null;\r\n }\r\n\r\n}"},"python":{"code":"n = int(input())\nm = int(input())\n\ndef get_maze_paths(sr, sc, dr, dc):\n #Write your code here\n \nans = get_maze_paths(0, 0, n-1, m-1)\n\nprint(\"[\"+', '.join(ans) + \"]\")"}},"points":10,"difficulty":"easy","sampleInput":"2\r\n2","sampleOutput":"[h1v1, v1h1, d1]","questionVideo":"https://www.youtube.com/embed/F6T3tD8Pw20","hints":[],"associated":[{"id":"18d5717c-849b-4cfb-95ed-fb58e7f8b3c7","name":"(Get Maze Paths with jumps) How many functions calls will be required for recursive solution of this question?","slug":"get-maze-paths-with-jumps-how-many-functions-calls-will-be-required-for-recursive-solution-of-this-question","type":4},{"id":"61647f16-07a7-4378-a335-542ee357486a","name":"(Get Maze Paths with jumps) What will be your output for destination row = 2 and destination column = 3","slug":"get-maze-paths-with-jumps-what-will-be-your-output-for-destination-row-2-and-destination-column-3","type":4},{"id":"66c6d83e-d489-4f5d-bbcc-878a635fdb82","name":"(Get Maze Paths with jumps) What will be the base conditions if dr and dc are destination row and destination columns ans cr and cc are current row and current columns for proactive call.","slug":"get-maze-paths-with-jumps-what-will-be-the-base-conditions-if-dr-and-dc-are-destination-row-and-destination-columns-ans-cr-and-cc-are-current-row-and-current-columns-for-proactive-call","type":4},{"id":"baea3333-3945-4162-b883-219435982177","name":"(Get Maze Paths with jumps) What is space and time complexity of the code?","slug":"get-maze-paths-with-jumps-what-is-space-and-time-complexity-of-the-code","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":"a6a44362-0973-4003-a556-b1225e979e75","name":"Get Maze Path With Jumps","slug":"get-maze-path-with-jumps","type":1}],"next":{"id":"bdaf583e-a53c-49a6-81f2-52fc05ce0352","name":"Get Maze Path With Jumps","type":3,"slug":"get-maze-path-with-jumps"},"prev":{"id":"faf3f244-a011-4897-ba1f-2189f3051989","name":"Get Maze Paths","type":3,"slug":"get-maze-paths"}}}
plane

Editor


Loading...

Get Maze Path With Jumps

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. 3. In a single move you are allowed to jump 1 or more steps horizontally (as h1, h2, .. ), or 1 or more steps vertically (as v1, v2, ..) or 1 or more steps diagonally (as d1, d2, ..). 4. Complete the body of getMazePath function - without changing signature - to get 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

Contents of the arraylist containing paths as shown in sample output

Example

Sample Input

2 2

Sample Output

[h1v1, v1h1, d1]

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode