Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    Practice problems / Ways to make change

    Ways to make change

    Mediumdynamic programmingarray

    Return how many different ways coins can make amount (each coin may repeat). Order doesn't matter: 1+2 and 2+1 are the same way.

    Example 1

    Input:  amount = 5, coins = [1,2,5]
    Output: 4

    5, 2+2+1, 2+1+1+1, 1+1+1+1+1.

    Example 2

    Input:  amount = 3, coins = [2]
    Output: 0

    Constraints

    • 0 ≤ amount ≤ 1000
    • 1 ≤ coins.length ≤ 100
    • Coins are distinct, 1 ≤ coins[i] ≤ 1000
    • The answer fits in 64 bits

    Submit checks your solution against 9 tests, including hidden ones.

    /**
     * @param {int} amount
     * @param {int[]} coins
     * @return {long}
     */
    function change(amount, coins) {
      
    }
    
    Sign in to run
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.