Minimum Number of Coins Problem

Dora, on her visit to India, decides to enjoy Indian cuisine where payments are accepted only in specific denominations. Your task is to help Dora obtain the minimum number of coins for a given amount using the available denominations of [1, 2, 5, 10, 20, 50, 100, 500, 1000]. The bank has an unlimited supply of these denominations.

Explanation:

For a provided amount, determine the least number of coins needed to make up that amount.

Input:

The first line contains an integer 'T', the number of test cases. Each of the next 'T' lines contains a single integer 'Amount'.

Output:

For each test case, output the minimum number of coins required on a new line.

Example:

Input:
2
70
121
Output:
2
3
Explanation:

For Amount = 70, coins of Rs. 50 and Rs. 20 can be used. For Amount = 121, coins of Rs. 100, Rs. 20, and Rs. 1 can be used.

Constraints:

  • 1 <= T <= 100
  • 1 <= Amount <= 105
Note:

It is guaranteed that a solution exists for each input Amount provided.

AnswerBot
4mo

Find the minimum number of coins needed to make up a given amount using specific denominations.

  • Iterate through the available denominations in descending order

  • For each denomination, calculate the maxim...read more

Help your peers!
Select
Add answer anonymously...

Paytm Software Engineer interview questions & answers

A Software Engineer was asked 7mo agoQ. Given an m x n matrix, where each row and each column is sorted in ascending ord...read more
A Software Engineer was asked 9mo agoQ. Explain the internal workings of a hashmap.
A Software Engineer was asked 9mo agoQ. Given head, the head of a linked list, determine if the linked list has a cycle ...read more

Popular interview questions of Software Engineer

A Software Engineer was asked 7mo agoQ1. Given an m x n matrix, where each row and each column is sorted in ascending ord...read more
A Software Engineer was asked 9mo agoQ2. Explain the internal workings of a hashmap.
A Software Engineer was asked 9mo agoQ3. Given head, the head of a linked list, determine if the linked list has a cycle ...read more
Paytm Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits