# Generate Parentheses

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/1594/generate-parentheses
Source observed: 2026-11-04T23:17:52.288Z
Last checked: 2026-11-04T23:17:52.288+00:00
Indexed: 2026-11-05T06:50:56.253+00:00

---

# Generate Parentheses

We provide this **Medium** difficulty **Data Structures & Algorithms** and **Coding** interview question. It is associated with **6 interviews** and was reported as last asked **7 months ago**. Listed roles include **Software Engineer**, **Machine Learning Engineer**, and **Data Engineer**; listed companies include **Meta, Oracle, Tesla, Adobe, Walmart Labs, and Google**. Detailed company statistics require an [Upgrade](https://www.aced.io/upgrade?src=questions).

## Question

Generate all combinations of well-formed parentheses. A combination is well-formed when every opening parenthesis `(` is closed by a matching closing parenthesis `)` in the correct order.

Examples of well-formed combinations are `()`, `()()`, and `((()))`. Examples that are not well-formed are `)(`, `((`, and `(()`.

### Examples

```text
n = 1
output: ["()"]

n = 2
output: ["(())", "()()"]

n = 3
output: ["((()))", "(()())", "(())()", "()(())", "()()()"]

n = 4
output should contain: ["(((())))", "((()()))", "((())())", "((()))()", "(()(()))", "(()()())", "(()())()", "(())(())", "(())()()", "()((()))", "()(()())", "()(())()", "()()(())", "()()()()"]
```

The question interface includes **Question**, locked **Solution**, locked **Mock Interview**, and **Community 18** tabs. Its coding panel includes an editor, sharing, output, test results, and console areas. The captured panel was still loading; [sign up to run code](https://www.aced.io/signup?src=lesson).

## Interview experience

One **Meta** experience was shared for a **Software Engineer · Senior / L5** role: [read the experience](https://www.aced.io/experiences/meta-facebook-senior-software-engineer-interview-2e6660).

The candidate said Meta remains heavily focused on LeetCode-style interviews and that medium-to-hard questions should be expected. They found this format predictable and easy to prepare for. They reported that, on the second question, they could not walk through the code with an example because of time constraints and spent too long explaining both approaches. Their advice was to keep thoughts concise and finish the code quickly so both questions can be completed.

## Community answers

No answers have been contributed by the community yet.

## Related questions

- [Valid Parentheses](https://www.aced.io/questions/3447/valid-parentheses)
- [Longest Valid Parentheses](https://www.aced.io/questions/7102/find-longest-valid-parentheses)

## 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 for ML roles at Meta, Google, Amazon, Apple, Microsoft, Nvidia, and other companies, including ML system design, core concepts, coding, and behavioral interviews.

### [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 cover mock interviews, frameworks, and advice from senior candidates for data-engineering roles at Meta, Google, Amazon, Microsoft, Walmart, DoorDash, and other companies, including data modeling, pipeline design, SQL, coding, and behavioral interviews.

## Your answer

Submitting an answer marks this question complete.

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F1594%2Fgenerate-parentheses&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%2F1594%2Fgenerate-parentheses). Opening a form does not execute a tool.