Data Structures & AlgorithmsVery hardICPC regional · Amazon SDE OA
Using coins of value 5, 2 and 1, what is the minimum number of coins that make the amount 11?
- A. 4
- B. 2
- C. 3
- D. 5
Correct answer: C. 3
Greedy works for this coin system: 5 + 5 + 1 uses three coins, and a DP confirms it. Using 2s before checking the remainder can cost more.
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
- How many positive integers x satisfy x^2 <= 500?
- What is the minimum number of elements of [1, 3, 2, 5, 4, 6] that must be changed (values may be set arbitrarily) so that the array…
- How many trailing zeros does 25! have?
- How many index pairs i < j of [1, 2, 3, 4, 5, 6] have a product strictly less than 20?
- Evaluate the postfix expression "2 3 4 + 5 -".
- What is the length of the longest substring of "aabbaacc" in which every letter appears at most twice?