{"id":"a50b2b40-a895-4c4d-b3f3-011c86c9cfef","name":"Permutations - 2","description":"1. You are give a number of boxes (nboxes) and number of non-identical items (ritems).\r\n2. You are required to place the items in those boxes and print all such configurations possible.\r\n\r\nItems are numbered from 1 to ritems.\r\nNote 1 -> Number of boxes is greater than number of items, hence some of the boxes may remain \r\n empty.\r\nNote 2 -> Check out the question video and write the recursive code as it is intended without \r\n changing signature. The judge can't force you but intends you to teach a concept.","inputFormat":"Input is managed for you","outputFormat":"Check the sample ouput and question video. 0 means empty box.","constraints":"0 < nboxes <= 10\r\n0 <= ritems <= nboxes","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void permutations(int cb, int tb, int[] items, int ssf, int ts, String asf){\r\n // write your code here\r\n }\r\n\r\n public static void main(String[] args) throws Exception {\r\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\r\n int nboxes = Integer.parseInt(br.readLine());\r\n int ritems = Integer.parseInt(br.readLine());\r\n permutations(1, nboxes, new int[ritems], 0, ritems, \"\");\r\n }\r\n\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"5\r\n3","sampleOutput":"12300\r\n12030\r\n12003\r\n13200\r\n13020\r\n13002\r\n10230\r\n10203\r\n10320\r\n10302\r\n10023\r\n10032\r\n21300\r\n21030\r\n21003\r\n23100\r\n23010\r\n23001\r\n20130\r\n20103\r\n20310\r\n20301\r\n20013\r\n20031\r\n31200\r\n31020\r\n31002\r\n32100\r\n32010\r\n32001\r\n30120\r\n30102\r\n30210\r\n30201\r\n30012\r\n30021\r\n01230\r\n01203\r\n01320\r\n01302\r\n01023\r\n01032\r\n02130\r\n02103\r\n02310\r\n02301\r\n02013\r\n02031\r\n03120\r\n03102\r\n03210\r\n03201\r\n03012\r\n03021\r\n00123\r\n00132\r\n00213\r\n00231\r\n00312\r\n00321\r\n","questionVideo":"https://www.youtube.com/embed/NWFpebVkmTI?end=114","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":"082986ae-d618-4a59-9ab3-6d79056679a4","name":"Recursion and Backtracking For Intermediate","slug":"recursion-and-backtracking-for-intermediate-330","type":0},{"id":"ded14b19-e8ac-422a-8c12-f30d81a25ab9","name":"Permutations - 2","slug":"permutations-2","type":1}],"next":{"id":"7e6cbfcd-a36d-4454-8d32-97093f0d9dc3","name":"Permutations-2 MCQ","type":0,"slug":"permutations-2-mcq"},"prev":{"id":"333aad8b-e126-4d7a-a754-5017873e9708","name":"Combinations -1 MCQ","type":0,"slug":"combinations-1-mcq"}}}

Permutations - 2

1. You are give a number of boxes (nboxes) and number of non-identical items (ritems). 2. You are required to place the items in those boxes and print all such configurations possible. Items are numbered from 1 to ritems. Note 1 -> Number of boxes is greater than number of items, hence some of the boxes may remain empty. Note 2 -> Check out the question video and write the recursive code as it is intended without changing signature. The judge can't force you but intends you to teach a concept.

{"id":"a50b2b40-a895-4c4d-b3f3-011c86c9cfef","name":"Permutations - 2","description":"1. You are give a number of boxes (nboxes) and number of non-identical items (ritems).\r\n2. You are required to place the items in those boxes and print all such configurations possible.\r\n\r\nItems are numbered from 1 to ritems.\r\nNote 1 -> Number of boxes is greater than number of items, hence some of the boxes may remain \r\n empty.\r\nNote 2 -> Check out the question video and write the recursive code as it is intended without \r\n changing signature. The judge can't force you but intends you to teach a concept.","inputFormat":"Input is managed for you","outputFormat":"Check the sample ouput and question video. 0 means empty box.","constraints":"0 < nboxes <= 10\r\n0 <= ritems <= nboxes","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void permutations(int cb, int tb, int[] items, int ssf, int ts, String asf){\r\n // write your code here\r\n }\r\n\r\n public static void main(String[] args) throws Exception {\r\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\r\n int nboxes = Integer.parseInt(br.readLine());\r\n int ritems = Integer.parseInt(br.readLine());\r\n permutations(1, nboxes, new int[ritems], 0, ritems, \"\");\r\n }\r\n\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"5\r\n3","sampleOutput":"12300\r\n12030\r\n12003\r\n13200\r\n13020\r\n13002\r\n10230\r\n10203\r\n10320\r\n10302\r\n10023\r\n10032\r\n21300\r\n21030\r\n21003\r\n23100\r\n23010\r\n23001\r\n20130\r\n20103\r\n20310\r\n20301\r\n20013\r\n20031\r\n31200\r\n31020\r\n31002\r\n32100\r\n32010\r\n32001\r\n30120\r\n30102\r\n30210\r\n30201\r\n30012\r\n30021\r\n01230\r\n01203\r\n01320\r\n01302\r\n01023\r\n01032\r\n02130\r\n02103\r\n02310\r\n02301\r\n02013\r\n02031\r\n03120\r\n03102\r\n03210\r\n03201\r\n03012\r\n03021\r\n00123\r\n00132\r\n00213\r\n00231\r\n00312\r\n00321\r\n","questionVideo":"https://www.youtube.com/embed/NWFpebVkmTI?end=114","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":"082986ae-d618-4a59-9ab3-6d79056679a4","name":"Recursion and Backtracking For Intermediate","slug":"recursion-and-backtracking-for-intermediate-330","type":0},{"id":"ded14b19-e8ac-422a-8c12-f30d81a25ab9","name":"Permutations - 2","slug":"permutations-2","type":1}],"next":{"id":"7e6cbfcd-a36d-4454-8d32-97093f0d9dc3","name":"Permutations-2 MCQ","type":0,"slug":"permutations-2-mcq"},"prev":{"id":"333aad8b-e126-4d7a-a754-5017873e9708","name":"Combinations -1 MCQ","type":0,"slug":"combinations-1-mcq"}}}
plane

Editor


Loading...

Permutations - 2

medium

1. You are give a number of boxes (nboxes) and number of non-identical items (ritems). 2. You are required to place the items in those boxes and print all such configurations possible. Items are numbered from 1 to ritems. Note 1 -> Number of boxes is greater than number of items, hence some of the boxes may remain empty. Note 2 -> Check out the question video and write the recursive code as it is intended without changing signature. The judge can't force you but intends you to teach a concept.

Constraints

0 < nboxes <= 10 0 <= ritems <= nboxes

Format

Input

Input is managed for you

Output

Check the sample ouput and question video. 0 means empty box.

Example

Sample Input

5 3

Sample Output

12300 12030 12003 13200 13020 13002 10230 10203 10320 10302 10023 10032 21300 21030 21003 23100 23010 23001 20130 20103 20310 20301 20013 20031 31200 31020 31002 32100 32010 32001 30120 30102 30210 30201 30012 30021 01230 01203 01320 01302 01023 01032 02130 02103 02310 02301 02013 02031 03120 03102 03210 03201 03012 03021 00123 00132 00213 00231 00312 00321

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode