`{"id":"cd6345e5-475e-47f7-84e9-09190e2f20d5","name":"Coin Change - Permutations - 2","description":"1. You are given a number n, representing the count of coins.\r\n2. You are given n numbers, representing the denominations of n coins.\r\n3. You are given a number \"amt\".\r\n4. You are required to calculate and print the permutations of the n coins (same coin can be used again any number of times) using which the amount \"amt\" can be paid.\r\n\r\nNote -> Use the code snippet and follow the algorithm discussed in question video. The judge can't force you but the intention is to teach a concept. Play in spirit of the question.","inputFormat":"A number n\r\nn1\r\nn2\r\n.. n number of elements\r\nA number amt","outputFormat":"Check the sample output and question video","constraints":"1 &lt;= n &lt;= 30\r\n0 &lt;= n1, n2, .. n elements &lt;= 20\r\n0 &lt;= amt &lt;= 50","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 coinChange(int[] coins, int amtsf, int tamt, 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 n = Integer.parseInt(br.readLine());\r\n int[] coins = new int[n];\r\n for (int i = 0; i < n; i++) {\r\n coins[i] = Integer.parseInt(br.readLine());\r\n }\r\n int amt = Integer.parseInt(br.readLine());\r\n coinChange(coins, 0, amt, \"\");\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"3\r\n2\r\n3\r\n5\r\n7","sampleOutput":"2-2-3-.\r\n2-3-2-.\r\n2-5-.\r\n3-2-2-.\r\n5-2-.\r\n","questionVideo":"https://www.youtube.com/embed/yRqjQdCN7CE","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":"5c694d96-84c2-4264-8969-c2fc17ceab74","name":"Coin Change - Permutations - 2","slug":"coin-change-permutations-2","type":1}],"next":{"id":"8ac93298-87c6-42cd-9a59-9b5c87263c7d","name":"Coin Change - Permutations - 2 MCQ","type":0,"slug":"coin-change-permutations-2-mcq"},"prev":{"id":"dbdc0353-e495-4dd2-8278-7cb1de56a8f5","name":"Magnets MCQ","type":0,"slug":"magnets-mcq"}}}`

Coin Change - Permutations - 2

1. You are given a number n, representing the count of coins. 2. You are given n numbers, representing the denominations of n coins. 3. You are given a number "amt". 4. You are required to calculate and print the permutations of the n coins (same coin can be used again any number of times) using which the amount "amt" can be paid. Note -> Use the code snippet and follow the algorithm discussed in question video. The judge can't force you but the intention is to teach a concept. Play in spirit of the question.

`{"id":"cd6345e5-475e-47f7-84e9-09190e2f20d5","name":"Coin Change - Permutations - 2","description":"1. You are given a number n, representing the count of coins.\r\n2. You are given n numbers, representing the denominations of n coins.\r\n3. You are given a number \"amt\".\r\n4. You are required to calculate and print the permutations of the n coins (same coin can be used again any number of times) using which the amount \"amt\" can be paid.\r\n\r\nNote -> Use the code snippet and follow the algorithm discussed in question video. The judge can't force you but the intention is to teach a concept. Play in spirit of the question.","inputFormat":"A number n\r\nn1\r\nn2\r\n.. n number of elements\r\nA number amt","outputFormat":"Check the sample output and question video","constraints":"1 &lt;= n &lt;= 30\r\n0 &lt;= n1, n2, .. n elements &lt;= 20\r\n0 &lt;= amt &lt;= 50","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 coinChange(int[] coins, int amtsf, int tamt, 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 n = Integer.parseInt(br.readLine());\r\n int[] coins = new int[n];\r\n for (int i = 0; i < n; i++) {\r\n coins[i] = Integer.parseInt(br.readLine());\r\n }\r\n int amt = Integer.parseInt(br.readLine());\r\n coinChange(coins, 0, amt, \"\");\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"3\r\n2\r\n3\r\n5\r\n7","sampleOutput":"2-2-3-.\r\n2-3-2-.\r\n2-5-.\r\n3-2-2-.\r\n5-2-.\r\n","questionVideo":"https://www.youtube.com/embed/yRqjQdCN7CE","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":"5c694d96-84c2-4264-8969-c2fc17ceab74","name":"Coin Change - Permutations - 2","slug":"coin-change-permutations-2","type":1}],"next":{"id":"8ac93298-87c6-42cd-9a59-9b5c87263c7d","name":"Coin Change - Permutations - 2 MCQ","type":0,"slug":"coin-change-permutations-2-mcq"},"prev":{"id":"dbdc0353-e495-4dd2-8278-7cb1de56a8f5","name":"Magnets MCQ","type":0,"slug":"magnets-mcq"}}}`

Editor

Coin Change - Permutations - 2

medium

1. You are given a number n, representing the count of coins. 2. You are given n numbers, representing the denominations of n coins. 3. You are given a number "amt". 4. You are required to calculate and print the permutations of the n coins (same coin can be used again any number of times) using which the amount "amt" can be paid. Note -> Use the code snippet and follow the algorithm discussed in question video. The judge can't force you but the intention is to teach a concept. Play in spirit of the question.

Constraints

1 <= n <= 30 0 <= n1, n2, .. n elements <= 20 0 <= amt <= 50

Format

Input

A number n n1 n2 .. n number of elements A number amt

Output

Check the sample output and question video

Example

Sample Input

```.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}3 2 3 5 7```

Sample Output

```.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}2-2-3-. 2-3-2-. 2-5-. 3-2-2-. 5-2-. ```

Question Video

Discussions

Show Discussion

Related Resources