Data Structures & AlgorithmsHardTCS NQT Digital · Product Company SDE
Problem: How many ways can 10 be made using coins {1, 2, 5} where order does not matter (combinations of coin counts)?
- A. 10
- B. 128
- C. 6
- D. 2
Correct answer: A. 10
With the coin loop OUTSIDE the amount loop, each combination is counted once: 10 ways (e.g. 5+5, 5+2+2+1, …, ten 1s). Swapping the loops counts ordered sequences (128), using only coins 1 and 2 gives 6, and 2 is the minimum number of coins (5 + 5).
More Coding Interview Problems questions
- Problem: On a 3×3 matrix [[9,9,4],[6,6,8],[2,1,1]], a strictly increasing path moves up, down, left or right between adjacent cells with…
- Problem: The Collatz sequence starts at n = 27 and repeatedly applies: n → n/2 if n is even, n → 3n+1 if n is odd, until n = 1. How many…
- Problem: For the same Collatz process starting at n = 27, what is the largest value that appears in the sequence?
- Problem: The digital root of a positive integer is obtained by repeatedly summing its decimal digits until a single digit remains. What is…
- Problem: How many integers n with 1 ≤ n ≤ 1000 have decimal digits summing to exactly 10?
- Problem: What is the smallest positive integer n such that n! is divisible by 10⁶ (that is, n! has at least six trailing zeros in base 10)?