Data Structures & AlgorithmsHardGATE CS · TCS NQT
Coins of value 2, 3 and 5 are available in unlimited supply. In how many ways can you pay exactly 10 when the ORDER of coins does NOT matter (for example 2+3+5 and 5+3+2 count as the same way)?
- A. 14
- B. 4
- C. 2
- D. 8
Correct answer: B. 4
Unordered counting uses the outer loop over coins: each coin type is processed once, and the inner loop goes upward so a coin can repeat. Looping over the amount first, as an ordered count does, counts each permutation separately.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- In the binary array [1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1] you may flip at most ONE 0 to a 1. What is the length of the longest run of…
- What is the length of the longest STRICTLY increasing subsequence of [3, 10, 2, 1, 20, 4, 6, 7, 6, 7, 8, 2]?
- For the array [1, 3, 5, 4, 7, 2, 2, 8, 6, 9], how many DIFFERENT subsequences (chosen by index) are strictly increasing AND have the…
- What is the maximum possible SUM of a strictly increasing subsequence of [1, 101, 2, 3, 100, 4, 5]?
- The longest bitonic subsequence of an array is a subsequence that first strictly increases and then strictly decreases (either part may be…
- A pair (a, b) can follow pair (c, d) in a chain when b < c. The pairs are [(5, 24), (39, 60), (15, 28), (27, 40), (50, 90), (1, 2), (3…