# Candy — coding interview question

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/4491/candy
Source observed: 2026-11-04T23:46:10.061Z
Last checked: 2026-11-04T23:46:10.061+00:00
Indexed: 2026-11-06T17:01:42.119+00:00

---

# Candy

We provide this coding interview question in Aced’s questions library. Given an array of children’s ratings, assign at least one candy to every child so that any child with a higher rating than a neighboring child receives more candies. Return the minimum total number of candies required.

## Question details

- **Roles:** [Data Engineer](https://www.aced.io/questions?role=data-engineer), [Machine Learning Engineer](https://www.aced.io/questions?role=ml-engineer), [Software Engineer](https://www.aced.io/questions?role=swe)
- **Company:** [Amazon](https://www.aced.io/questions?company=amazon)
- **Categories:** [Data Structures & Algorithms](https://www.aced.io/questions?type=algorithms), [Coding](https://www.aced.io/questions?type=coding)
- **Interview history:** Reported last asked a year ago
- **Interview data:** 3 interviews

## Community answers

No community answers have been contributed yet. To submit an answer, [log in or sign up](https://www.aced.io/signup?src=nav&returnPath=/questions/4491/candy). Submitting an answer marks the question complete.

Detailed company statistics for this question are available through [Upgrade](https://www.aced.io/upgrade?src=questions).

## 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 help candidates prepare for machine learning roles at Meta, Google, Amazon, Apple, Microsoft, Nvidia, and other top companies with mock interviews, frameworks, and advice from senior candidates. Topics include ML system design, core concepts, coding, behavioral interviews, and more.

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

![Data Engineering Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/5XoOCgXlGqN2fa1zaroNWd/9a2e23df48a212bc00d352873feb2d6a/Data_Engineer_Interview_Prep_Hero_Image.jpg?w=800&h=800&fm=webp&q=75)

We help candidates prepare for data engineering roles at Meta, Google, Amazon, Microsoft, Walmart, DoorDash, and other top companies. The course covers data modeling, pipeline design, SQL, coding, behavioral interviews, mock interviews, frameworks, and advice from senior candidates.

## Explore Aced

Aced, formerly Exponent, offers interview preparation through courses, interview questions, practice, coaching, job referrals, and related resources.

- [Courses](https://www.aced.io/courses?src=nav)
- [Loops](https://www.aced.io/guides?src=nav)
- [Experiences](https://www.aced.io/experiences?src=nav)
- [Questions](https://www.aced.io/questions?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%2F4491%2Fcandy&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%2F4491%2Fcandy). Opening a form does not execute a tool.