GamifiedGamified challengesPracticeRaceLeaderboardPricing

Learn data structures by watching them move, then doing it yourself. Press M anytime to toggle sound.

A product of Amypo Technologies, Coimbatore.

Learn

  • All topics
  • Learning path
  • How it works
  • About dotprep

Practice

  • Practice arena
  • Daily challenge
  • Gamified challenges
  • Race mode
  • Leaderboard

Interview prep

  • Java interview
  • Coding questions
  • Company questions
  • System design
  • Jobs & careers

You

  • Dashboard
  • Settings
  • Pricing
  • Create account

© 2026 dotprep

Content last updated 20 November 2026

GamifiedGamified challengesPracticeRaceLeaderboardPricing
Log inStart free
Gamified challengesVending Machine Change

Gamified challenge · Unbounded knapsack DP

Vending Machine Change

coins lists the coin values the machine holds, and it has an unlimited supply of each. It must pay out exactly amount.

Write minCoins(coins, amount) (Python: min_coins) that returns the fewest coins that add up to amount, or -1 if no combination does. For coins = [1, 3, 4] and amount = 6 the answer is 2 (3 + 3), even though grabbing the biggest coin first gives 4 + 1 + 1.

Coins are positive and may come in any order. amount is between 0 and 200, and paying 0 takes 0 coins.

Sign in to play Vending Machine Change

This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.

Sign in with Google

or log in with email · create an account