As reported: Salesforce SMTS loop (Bangalore, OCI team, 2025), round 1 (DSA, two problems): a problem similar to Coin Change, then Search a 2D Matrix II. A variation of coin change was also asked in round 2 of a Salesforce SMTS hiring drive in Hyderabad (Nov 2024).
This is LeetCode 322 — Coin Change.
Given coin denominations coins (unlimited supply of each) and an amount, return the fewest coins that add up to amount, or -1 if it cannot be made. An amount of 0 needs 0 coins.
Example 1
coins = [1,2,5], amount = 11
Output: 3
5 + 5 + 1.
Example 2
coins = [2], amount = 3
Output: -1
Example 3
coins = [1], amount = 0
Output: 0
Constraints: 1 ≤ coins.length ≤ 12; 1 ≤ coins[i] ≤ 2^31 − 1; 0 ≤ amount ≤ 10^4.
Code runner format: one JSON value per line: coins, then amount. Implement coinChange(coins, amount); the harness prints the count.