`{"id":"7928296f-5e79-4ad9-ac21-c39372e8e7e8","name":"Coin Change - Permutations - 1","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 (non-duplicate) 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":"#include<bits/stdc++.h>\nusing namespace std;\nvoid coinChange(vector<int>coins,int amtsf,int tamt,string asf,vector<bool>used){\n //write your code here\n}\nint main(){\n int n;\n cin>>n;\n vector<int>coins(n);\n for(int i=0;i<n;i++){\n cin>>coins[i];\n }\n int amt;\n cin>>amt;\n vector<bool>used(n);\n for(int i=0;i<n;i++){\n used[i]=false;\n }\n coinChange(coins,0,amt,\"\",used);\n}"},"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, boolean[] used){\r\n // write your code here\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 boolean[] used = new boolean[coins.length];\r\n coinChange(coins, 0, amt, \"\", used);\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"5\r\n2\r\n3\r\n5\r\n6\r\n7\r\n12","sampleOutput":"2-3-7-.\r\n2-7-3-.\r\n3-2-7-.\r\n3-7-2-.\r\n5-7-.\r\n7-2-3-.\r\n7-3-2-.\r\n7-5-.","questionVideo":"https://www.youtube.com/embed/aqepijUkV6w","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":"68071d88-0cc8-4c6b-a511-98d1b4e90bbd","name":"Coin Change - Permutations - 1","slug":"coin-change-permutations-1","type":1}],"next":{"id":"00d819f9-90dc-45f2-950d-eb86ce8d6faa","name":"Coin Change - Permutations - 1 MCQ","type":0,"slug":"coin-change-permutations-1-mcq"},"prev":{"id":"8ac93298-87c6-42cd-9a59-9b5c87263c7d","name":"Coin Change - Permutations - 2 MCQ","type":0,"slug":"coin-change-permutations-2-mcq"}}}`

Coin Change - Permutations - 1

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 (non-duplicate) 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":"7928296f-5e79-4ad9-ac21-c39372e8e7e8","name":"Coin Change - Permutations - 1","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 (non-duplicate) 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":"#include<bits/stdc++.h>\nusing namespace std;\nvoid coinChange(vector<int>coins,int amtsf,int tamt,string asf,vector<bool>used){\n //write your code here\n}\nint main(){\n int n;\n cin>>n;\n vector<int>coins(n);\n for(int i=0;i<n;i++){\n cin>>coins[i];\n }\n int amt;\n cin>>amt;\n vector<bool>used(n);\n for(int i=0;i<n;i++){\n used[i]=false;\n }\n coinChange(coins,0,amt,\"\",used);\n}"},"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, boolean[] used){\r\n // write your code here\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 boolean[] used = new boolean[coins.length];\r\n coinChange(coins, 0, amt, \"\", used);\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"5\r\n2\r\n3\r\n5\r\n6\r\n7\r\n12","sampleOutput":"2-3-7-.\r\n2-7-3-.\r\n3-2-7-.\r\n3-7-2-.\r\n5-7-.\r\n7-2-3-.\r\n7-3-2-.\r\n7-5-.","questionVideo":"https://www.youtube.com/embed/aqepijUkV6w","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":"68071d88-0cc8-4c6b-a511-98d1b4e90bbd","name":"Coin Change - Permutations - 1","slug":"coin-change-permutations-1","type":1}],"next":{"id":"00d819f9-90dc-45f2-950d-eb86ce8d6faa","name":"Coin Change - Permutations - 1 MCQ","type":0,"slug":"coin-change-permutations-1-mcq"},"prev":{"id":"8ac93298-87c6-42cd-9a59-9b5c87263c7d","name":"Coin Change - Permutations - 2 MCQ","type":0,"slug":"coin-change-permutations-2-mcq"}}}`

Editor

Coin Change - Permutations - 1

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 (non-duplicate) 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;}5 2 3 5 6 7 12```

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-3-7-. 2-7-3-. 3-2-7-. 3-7-2-. 5-7-. 7-2-3-. 7-3-2-. 7-5-.```

Question Video

Discussions

Show Discussion

Related Resources