Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Coin Change Ways
00:00
5 left

Coin Change Ways

MediumPython

Problem

Quid's media intelligence workflows may need to count valid combinations of fixed-value analysis credits. Given an amount and a set of coin denominations, return the number of combinations that produce the amount when each denomination can be used unlimited times.

The order of coins does not matter, so [1, 2] and [2, 1] represent the same combination. Return the exact count as a Python integer.

Formal Specification

Implement count_change(amount, coins).

  • amount is a non-negative integer.
  • coins is a list of distinct positive integers.
  • Return an integer representing the number of order-independent combinations whose values sum to amount.
  • Return 1 for amount 0, because choosing no coins is one valid combination.
  • Return 0 when no combination exists.

Constraints

  • 0 <= amount <= 10^4
  • 1 <= len(coins) <= 100
  • 1 <= coins[i] <= 10^4
  • All coin denominations are distinct positive integers
  • Each denomination may be used unlimited times
  • The result must be returned exactly

Function Signature

def count_change(amount, coins):
Interviewer

Your question is Coin Change Ways. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.