# Balance Parentheses by Removing the Fewest Characters

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/4537/balance-parentheses-string-manipulation
Source observed: 2026-11-05T00:19:24.609Z
Last checked: 2026-11-05T00:19:24.609+00:00
Indexed: 2026-11-06T01:47:14.259+00:00

---

# Given a string with parentheses, write a function that removes the minimum number of characters to balance the parentheses.

This is an Aced coding interview question associated with **Meta** and the **Machine Learning Engineer** role. It is categorized under **Data Structures & Algorithms** and **Coding**.

## Question details

- **Interview record:** 1 interview
- **Reported last asked:** 2 years ago
- **Community answers:** None contributed yet
- **Actions:** Mark as asked, save, or submit an answer. Submitting marks this question complete.

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

## Related questions

- [Determine the minimum number of parentheses needed to balance a given string.](https://www.aced.io/questions/3430/minimum-parentheses-balance-string)
- [Write a function to balance parentheses in a given string by removing the fewest characters possible. Ensure that each opening parenthesis has a corresponding closing parenthesis and each pair is p...](https://www.aced.io/questions/4214/balance-parentheses-minimum-removals)
- [Given a list of items with different sizes, write an algorithm to pack these items into the minimum number of batches without exceeding the capacity of each batch.](https://www.aced.io/questions/4910/batch-packing-bin-optimization)

## Related courses

![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)

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

Land your dream machine learning role at Meta, Google, Amazon, Apple, Microsoft, Nvidia, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates. Explore ML system design, core concepts, coding, behavioral interviews, and more.

![Behavioral Interviews: A Practical Guide for Engineers](https://images.ctfassets.net/x78yjrjc11pq/47qcoHjzFZXE37GoacedkB/9d8e3f4910d8b06b21e76745cd9cbff3/AdobeStock_1142146335.jpeg?w=800&h=800&fm=webp&q=75)

### [Behavioral Interviews: A Practical Guide for Engineers](https://www.aced.io/courses/eng-behavioral)

Get offers at the level you deserve. Prepare for senior+ behavioral interviews at FAANG and Tier-1 companies with material made with staff and principal engineers from Meta, Netflix, Google, and more. Topics include avoiding downleveling, elevating past projects, and avoiding robotic answers.

## Submit an answer

You must log in or sign up to answer this question. [Log in](https://www.aced.io/login?src=nav) or [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%2F4537%2Fbalance-parentheses-string-manipulation&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%2F4537%2Fbalance-parentheses-string-manipulation). Opening a form does not execute a tool.