{"id":"1b326582-d38d-4dc5-bfff-6bdb411f4338","name":"Combinations - 2","description":"1. You are give a number of boxes (nboxes) and number of 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 identical and all of them are named 'i'\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.\r\n","inputFormat":"Input is managed for you","outputFormat":"Check the sample ouput and question video. - means empty box, i means occupied by item.\r\n","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 combinations(int[] boxes, int ci, int ti, int lb){\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 combinations(new int[nboxes], 1, ritems, -1);\r\n }\r\n\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"5\r\n3","sampleOutput":"iii--\r\nii-i-\r\nii--i\r\ni-ii-\r\ni-i-i\r\ni--ii\r\n-iii-\r\n-ii-i\r\n-i-ii\r\n--iii","questionVideo":"https://www.youtube.com/embed/f6cL-VMIfTY?end=172","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":"636d5e5a-f198-4da7-b68f-f521d71e8dda","name":"Combinations - 2","slug":"combinations-2","type":1}],"next":{"id":"dc4173ce-df9e-4001-bddd-c8d45da467a8","name":"Combinations -2 MCQ","type":0,"slug":"combinations-2-mcq"},"prev":{"id":"7e6cbfcd-a36d-4454-8d32-97093f0d9dc3","name":"Permutations-2 MCQ","type":0,"slug":"permutations-2-mcq"}}}

Combinations - 2

1. You are give a number of boxes (nboxes) and number of identical items (ritems). 2. You are required to place the items in those boxes and print all such configurations possible. Items are identical and all of them are named 'i' 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":"1b326582-d38d-4dc5-bfff-6bdb411f4338","name":"Combinations - 2","description":"1. You are give a number of boxes (nboxes) and number of 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 identical and all of them are named 'i'\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.\r\n","inputFormat":"Input is managed for you","outputFormat":"Check the sample ouput and question video. - means empty box, i means occupied by item.\r\n","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 combinations(int[] boxes, int ci, int ti, int lb){\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 combinations(new int[nboxes], 1, ritems, -1);\r\n }\r\n\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"5\r\n3","sampleOutput":"iii--\r\nii-i-\r\nii--i\r\ni-ii-\r\ni-i-i\r\ni--ii\r\n-iii-\r\n-ii-i\r\n-i-ii\r\n--iii","questionVideo":"https://www.youtube.com/embed/f6cL-VMIfTY?end=172","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":"636d5e5a-f198-4da7-b68f-f521d71e8dda","name":"Combinations - 2","slug":"combinations-2","type":1}],"next":{"id":"dc4173ce-df9e-4001-bddd-c8d45da467a8","name":"Combinations -2 MCQ","type":0,"slug":"combinations-2-mcq"},"prev":{"id":"7e6cbfcd-a36d-4454-8d32-97093f0d9dc3","name":"Permutations-2 MCQ","type":0,"slug":"permutations-2-mcq"}}}
plane

Editor


Loading...

Combinations - 2

medium

1. You are give a number of boxes (nboxes) and number of identical items (ritems). 2. You are required to place the items in those boxes and print all such configurations possible. Items are identical and all of them are named 'i' 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. - means empty box, i means occupied by item.

Example

Sample Input

5 3

Sample Output

iii-- ii-i- ii--i i-ii- i-i-i i--ii -iii- -ii-i -i-ii --iii

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode