Data Structures & AlgorithmsVery hardTCS NQT Digital · Product Company SDE
Problem: With coin denominations 1, 7 and 10, what is the minimum number of coins needed to make 97?
- A. 16
- B. 10
- C. 19
- D. 97
Correct answer: B. 10
The DP over amounts gives 9 × 10 + 7 = 97 with 10 coins; using more 7s only adds coins (8 tens need 2 sevens and 3 ones). Using only 10s and 1s gives 16, only 7s and 1s gives 13 + 6 = 19, and 97 is the all-ones count.
More Coding Interview Problems questions
- Problem: Job sequencing: five jobs (deadline, profit) are (2, 100), (1, 19), (2, 27), (1, 25), (3, 15). Each job takes one unit of time…
- Problem: Boats carry at most 2 people and a weight limit of 10 per boat. Four people weigh 3, 5, 3 and 4. What is the minimum number of…
- Problem: What is the smallest integer x with x·x ≥ 1,000,000,000?
- Problem: A grid holds oranges: 2 = rotten, 1 = fresh, 0 = empty: [[2,1,1],[1,1,0],[0,1,1]]. Each minute every fresh orange adjacent…
- Problem: Courses 0–5 have prerequisites: 1 needs 0, 2 needs 1, 3 needs 2, 4 needs 5, 5 needs 4. A course can be taken only after all its…
- Problem: Buses run fixed routes; from a stop, the number of distinct routes is what matters. Given the four routes [1,2,7], [3,6,7]…