3116. Kth Smallest Amount With Single Denomination Combination
3116. Kth Smallest Amount With Single Denomination Combination
Description
You are given an integer array coins
representing coins of different denominations and an integer k
.
You have an infinite number of coins of each denomination. However, you are not allowed to combine coins of different denominations.
Return the k^th
smallest amount that can be made using these coins.
Example 1:
1 | Input: coins = [3,6,9], k = 3 |
Example 2:
1 | Input: coins = [5,2], k = 7 |
Constraints:
1 <= coins.length <= 15
1 <= coins[i] <= 25
1 <= k <= 2 * 10^9
coins
contains pairwise distinct integers.
Hints/Notes
- binary search
- Principle of inclusion-exclusion
Solution
Language: C++
1 | class Solution { |