PracHub
QuestionsPremiumLearningGuidesCheatsheetNEW
|Home/Coding & Algorithms/Snowflake

Minimize coins with overpay and change

Last updated: Apr 29, 2026

Quick Overview

This question evaluates algorithmic optimization and combinatorial reasoning in the coin-change domain, measuring proficiency with efficient numeric manipulation, counting strategies, and handling of fixed coin denominations.

  • hard
  • Snowflake
  • Coding & Algorithms
  • Software Engineer

Minimize coins with overpay and change

Company: Snowflake

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

You have an unlimited number of coins with denominations: - `1, 5, 10, 50, 100, 200` You need to pay exactly `n` units to another person. You are allowed to **overpay**, and the other person will always be able to give you **exact change** (they also have unlimited coins). Define the **total coins used** as: - the number of coins you give to pay, **plus** - the number of coins you receive back as change. Return the **minimum possible total number of coins** needed to complete the transaction. ### Input - A single integer `n`. ### Output - A single integer: the minimum total number of coins exchanged. ### Example **Input:** ``` 41 ``` **Output:** ``` 3 ``` **Explanation:** Pay `50 + 1` (2 coins) and receive `10` as change (1 coin), total `2 + 1 = 3`. ### Constraints - Assume `0 ≤ n ≤ 10^9`. - Both payer and receiver have unlimited coins of each denomination.

Quick Answer: This question evaluates algorithmic optimization and combinatorial reasoning in the coin-change domain, measuring proficiency with efficient numeric manipulation, counting strategies, and handling of fixed coin denominations.

Related Interview Questions

  • Solve Array Distance and Wiki Navigation - Snowflake (medium)
  • Implement Document Predicate APIs - Snowflake (medium)
  • Find Shortest Wiki Click Path - Snowflake (medium)
  • Schedule prerequisite classes with retakes - Snowflake (easy)
  • Solve three coding rounds - Snowflake (medium)
Snowflake logo
Snowflake
Mar 1, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
5
0
Coding Console
Loading...

You have an unlimited number of coins with denominations:

  • 1, 5, 10, 50, 100, 200

You need to pay exactly n units to another person. You are allowed to overpay, and the other person will always be able to give you exact change (they also have unlimited coins).

Define the total coins used as:

  • the number of coins you give to pay, plus
  • the number of coins you receive back as change.

Return the minimum possible total number of coins needed to complete the transaction.

Input

  • A single integer n .

Output

  • A single integer: the minimum total number of coins exchanged.

Example

Input:

41

Output:

3

Explanation: Pay 50 + 1 (2 coins) and receive 10 as change (1 coin), total 2 + 1 = 3.

Constraints

  • Assume 0 ≤ n ≤ 10^9 .
  • Both payer and receiver have unlimited coins of each denomination.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Snowflake•More Software Engineer•Snowflake Software Engineer•Snowflake Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.