Data Structures & AlgorithmsHardGATE CS · ICPC regional
What is the minimum number of coins needed to make 63 from the denominations 1, 5, 10, 21 and 25 (unlimited supply of each)?
- A. 3
- B. 4
- C. 5
- D. 7
Correct answer: A. 3
Greedy takes 25 + 25 + 10 + 1 + 1 + 1 = 6 coins, but 21 + 21 + 21 = 63 uses only 3. Coin change with a DP over amounts is needed for non-canonical systems.
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
- What is the length of the longest strictly increasing subsequence of [10, 9, 2, 5, 3, 7, 101, 18]?
- How many valid balanced bracket strings with 3 pairs begin with an opening bracket and are balanced, where the string has exactly 6…
- Which algorithm computes the length of the longest increasing subsequence in O(n log n) time?
- To count distinct values in every window of size k of an array in O(n) total time, which structure is most suitable?
- Stably sort the positions of -3 2 -2 1 3 -1 by the ABSOLUTE value of the element at each position (ascending), keeping the input order for…
- How many index pairs i < j in 1 3 2 5 4 6 8 satisfy A[j] − A[i] = j − i?