PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Walmart Labs

Count ways to make change (DP)

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of dynamic programming and combinatorial counting, focusing on unbounded coin usage and counting order‑independent combinations.

  • medium
  • Walmart Labs
  • Coding & Algorithms
  • Software Engineer

Count ways to make change (DP)

Company: Walmart Labs

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem You are given an integer `amount` and an array of **positive, distinct** integers `coins`, where each coin value can be used **unlimited times**. Return the number of **distinct combinations** of coins that sum to exactly `amount`. Notes: - The **order does not matter**. For example, `2+1` and `1+2` are the same combination. - If `amount = 0`, there is exactly **one** way: choose no coins. ## Input/Output - **Input:** integer `amount`, integer array `coins` - **Output:** integer `ways` ## Examples - `amount = 5, coins = [1,2,5]` → `4` - Combinations: `5`, `2+2+1`, `2+1+1+1`, `1+1+1+1+1` - `amount = 3, coins = [2]` → `0` - `amount = 0, coins = [1,2]` → `1` ## Constraints (assume) - `0 ≤ amount ≤ 10^4` - `1 ≤ len(coins) ≤ 300` - Result fits in 64-bit signed integer

Quick Answer: This question evaluates understanding of dynamic programming and combinatorial counting, focusing on unbounded coin usage and counting order‑independent combinations.

Related Interview Questions

  • Implement lexicographically smallest Two Sum - Walmart Labs (medium)
  • Check whether brackets are balanced - Walmart Labs (medium)
  • Compute days until plants stop dying - Walmart Labs (medium)
  • Find shared courses between student pairs - Walmart Labs (medium)
  • Merge two sorted arrays in-place - Walmart Labs (easy)
Walmart Labs logo
Walmart Labs
Mar 1, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
5
0
Loading...

Problem

You are given an integer amount and an array of positive, distinct integers coins, where each coin value can be used unlimited times.

Return the number of distinct combinations of coins that sum to exactly amount.

Notes:

  • The order does not matter . For example, 2+1 and 1+2 are the same combination.
  • If amount = 0 , there is exactly one way: choose no coins.

Input/Output

  • Input: integer amount , integer array coins
  • Output: integer ways

Examples

  • amount = 5, coins = [1,2,5] → 4
    • Combinations: 5 , 2+2+1 , 2+1+1+1 , 1+1+1+1+1
  • amount = 3, coins = [2] → 0
  • amount = 0, coins = [1,2] → 1

Constraints (assume)

  • 0 ≤ amount ≤ 10^4
  • 1 ≤ len(coins) ≤ 300
  • Result fits in 64-bit signed integer

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Walmart Labs•More Software Engineer•Walmart Labs Software Engineer•Walmart Labs Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,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.