Company: Barclays
Difficulty: medium
# Minimum Coins for Purchase You are given `N` distinct positive coin denominations and an exact purchase amount `X`. You may use any denomination an unlimited number of times. Find the minimum number of coins whose values sum exactly to `X`. Print `-1` if exact payment is impossible. ## Input Format - The first line contains `N`. - The second line contains `X`. - The third line contains `N` space-separated denominations. ## Output Format Print the minimum number of coins, or `-1` if no exact payment exists. ## Constraints - `1 <= N <= 100` - `0 <= X <= 100000` - `1 <= coin[i] <= 100000` - All denominations are distinct. ## Example Input: 3 11 1 5 7 Output: 3 ## Notes - For `X = 0`, the answer is `0`. - The order of selected coins does not matter.