Oh My Algorithm
Algorithm Guidecomplexity: O(n)

동전 거스름돈 (Coin Change)

가장 큰 동전부터 욕심껏 사용해 거스름돈을 만드는 그리디 전략입니다. 화폐 단위가 배수 관계(예: 500·100·50·10)일 때 최적이지만, 일반적인 단위에서는 최소 개수를 보장하지 못합니다.

01 Explore How It Works

Interactive Step-by-Step
Coin Change · target=760
remaining760
coins
500
100
50
10
picked · 0

거스름돈 760원을 만듭니다. 가장 큰 동전부터 욕심껏(greedy) 사용합니다.

Logic Node1 / 7

02 Understand It Simply

For Everyone
🔑Analogy

거스름돈을 줄 때 큰 동전부터 꺼내 금액을 빨리 줄이는 습관과 같습니다.

💡In Plain Words

매 순간 쓸 수 있는 가장 큰 동전을 욕심껏 고릅니다.

화폐가 배수 관계면 최소 개수가 보장되지만, 일반적인 단위에서는 실패할 수도 있어요.

📍Where It's Used
  • 거스름돈 계산
  • 단위가 정해진 자원 배분

03 Python Implementation

A clean, readable reference implementation of the core logic of 동전 거스름돈 (Coin Change).

core_implementation.py
def coin_change_greedy(coins, amount):
    coins = sorted(coins, reverse=True)
    result = []
    for coin in coins:
        while amount >= coin:
            amount -= coin
            result.append(coin)
    return result if amount == 0 else None

04 Frequently Asked Questions

FAQ
What is 동전 거스름돈 (Coin Change)?+

가장 큰 동전부터 욕심껏 사용해 거스름돈을 만드는 그리디 전략입니다. 화폐 단위가 배수 관계(예: 500·100·50·10)일 때 최적이지만, 일반적인 단위에서는 최소 개수를 보장하지 못합니다.

What is the time complexity of 동전 거스름돈 (Coin Change)?+

The time complexity of 동전 거스름돈 (Coin Change) is O(n). Follow the step-by-step visualization to see exactly why.

Where is 동전 거스름돈 (Coin Change) used?+

거스름돈 계산, 단위가 정해진 자원 배분.

What's a simple analogy for 동전 거스름돈 (Coin Change)?+

거스름돈을 줄 때 큰 동전부터 꺼내 금액을 빨리 줄이는 습관과 같습니다.

Guide Progress0%