# Coin Change coding question | Aced

Aced (formerly Exponent) publishes a public search API over its indexed pages; the guide is at https://www.aced.io/agents/agent-access.

Source: https://www.aced.io/questions/1142/coin-change
Source observed: 2026-11-05T00:20:33.986Z
Last checked: 2026-11-05T00:20:33.986+00:00
Indexed: 2026-11-06T23:31:52.455+00:00

---

# Coin Change

**Difficulty:** Medium  
**Category:** Coding / Technical

## Problem

You are given an integer array `coins` representing different coin denominations and an integer `amount` representing a total amount of money. Write a function `coinChange` that returns the fewest number of coins needed to make up that amount. If the amount cannot be made up by any combination of the coins, return `-1`.

You may assume that you have an infinite number of each kind of coin.

## Examples

```text
Input: coins = [1, 2, 5], amount = 11
Output: 3
Explanation: The minimum number of coins needed is 3 (11 = 5 + 5 + 1).

Input: coins = [4, 5], amount = 7
Output: -1
Explanation: It is not possible to make up the amount 7 with coins of denominations 4 and 5.
```

The interactive editor includes Python as the displayed language, with **Editor**, **Share**, **Output**, **Test Results**, and **Console** controls. Running code requires an account: [Sign up to run code](https://www.aced.io/signup?src=lesson).

## Question details

The question is associated with these roles and companies:

- [Software Engineer](https://www.aced.io/questions?role=swe) — 3
- [Machine Learning Engineer](https://www.aced.io/questions?role=ml-engineer) — 2
- [Backend Engineer](https://www.aced.io/questions?role=backend-engineer)
- [Data Scientist](https://www.aced.io/questions?role=data-science)
- [HP](https://www.aced.io/questions?company=hp) — 2
- [Apple](https://www.aced.io/questions?company=apple) — 2
- [Google](https://www.aced.io/questions?company=google)
- [Meta](https://www.aced.io/questions?company=meta-facebook)
- [Citi](https://www.aced.io/questions?company=citi-group)

The rendered question metadata also indicates **27 interviews**, and the question was last asked **8 months ago**. Interview counts and relative timing are displayed metadata rather than a solution to the coding problem.

## Interview experiences

Two shared interview experiences are associated with this question:

### [Google · 10 months ago](https://www.aced.io/experiences/google-machine-learning-engineer-intern-interview-d43fed)

**Role:** Machine Learning Engineer · Intern

> I interviewed for an AI Engineer internship, but the process was mostly DSA-heavy. I had an online coding round first, then a technical round with binary tree and DP questions, then another harder DSA round with DP and linked list questions, and finally an HR round. The online round covered arrays and strings, and the later rounds got progressively more difficult. The only non-DSA part was the last round, where they asked about my projects and previous experience. I didn't share the final outcome, but the main thing that stood out to me was how coding-focused the whole process was.

### [Meta · a year ago](https://www.aced.io/experiences/meta-facebook-software-engineer-interview-9165d4)

**Role:** Software Engineer · Mid Level / L4

> I got HR reach out, and start to prepare the interview around 2 weeks I didn't complete the coding section. Having some diffcult to communacate with the interview

## Related courses

### [Machine Learning Engineer Interview Prep](https://www.aced.io/courses/ml-engineer)

![Machine Learning Engineer Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/6UfkHxUyLQVfDHSfLNQtWa/1be1539a65b4f6f15201f5b573c0a578/ML_Engineer_Interview_Prep_Course.jpeg?w=800&h=800&fm=webp&q=75)

We cover mock interviews, frameworks, and advice from senior candidates, including ML system design, core concepts, coding, behavioral interviews, and more. The course is intended to help candidates prepare for machine learning roles at Meta, Google, Amazon, Apple, Microsoft, Nvidia, and other top companies.

### [Data Science Interview Prep](https://www.aced.io/courses/data-science)

![Data Science Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/3U4C5C0OkDR0UeGch4AmlE/7ad489430b676a088cb973307fe77884/Data_Science_Interview_Prep_Course.jpeg?w=800&h=800&fm=webp&q=75)

We cover statistics, experimentation, coding, SQL, machine learning, behavioral interviews, mock interviews, frameworks, and advice from senior candidates. The course is intended to help candidates prepare for data science roles at Google, Amazon, Microsoft, Meta, Apple, and other top companies.

## Explore Aced

We provide interview preparation through courses, interview experiences, coding questions, practice, and coaching. Our listed course areas include Product Management, Forward Deployed Engineering, Engineering Management, Software Engineering, System Design, Data Science, Machine Learning, and Data Engineering, with additional areas including AI Engineering, Investment Banking, Generative AI, Security Engineer, TPM, Solutions Architect, UX / Product Design, and BizOps & Strategy.

- [All questions](https://www.aced.io/questions)
- [Coding questions](https://www.aced.io/questions?type=algorithms&filterBy=codeEditor&src=nav)
- [Experiences](https://www.aced.io/experiences?src=nav)
- [Courses](https://www.aced.io/courses?src=nav)
- [Practice](https://www.aced.io/practice?src=nav)
- [Coaching](https://www.aced.io/coaching?src=nav)
- [Pricing](https://www.aced.io/upgrade?src=nav)
- [Log in](https://www.aced.io/login?src=nav)
- [Sign up](https://www.aced.io/signup?src=nav)

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F1142%2Fcoin-change&trace=t_679ff9ab98f3)

## Ask a follow-up about this page

Need a more specific answer? Ask the exact question you have. It returns a fresh, cited answer from Aced (formerly Exponent)’s knowledge base. No account or API key required.

Open this URL with your own question, URL-encoded. Include your question in q. All research inputs are optional; no account or setup.

`GET https://www.aced.io/agents/agent/faq?q={question}&trace=t_679ff9ab98f3`

[Tool guide and examples](https://www.aced.io/agents/agent-access) · [OpenAPI](https://www.aced.io/agents/api/public/v1/openapi.json) · [Page TLDR form](https://www.aced.io/agents/agent-tools/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F1142%2Fcoin-change). Opening a form does not execute a tool.