# Valid Parentheses — 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/3447/valid-parentheses
Source observed: 2026-11-04T21:34:29.869Z
Last checked: 2026-11-04T21:34:29.869+00:00
Indexed: 2026-11-05T02:42:27.309+00:00

---

# Valid Parentheses

**Difficulty:** Easy  
**Category:** [Data Structures & Algorithms](https://www.aced.io/questions?type=algorithms&filterBy=codeEditor&src=nav)  
**Reported last asked:** a month ago  
**Interview reports:** 19  
**Save count:** 76

We provide this coding-practice question for preparing for technical interviews. The task is to implement `isValid` for a string containing only `(`, `)`, `{`, `}`, `[`, and `]`.

## Problem

Return `true` when:

1. Every opening bracket is closed by the same type of bracket.
2. Opening brackets are closed in the correct order.

Return `false` otherwise.

### Examples

```text
Input: s = "({"
Output: false

Input: s = "({[]()})"
Output: true
```

The first example is invalid because the brackets are not fully closed. The second is valid because every bracket type is matched and nested correctly.

### Constraint

- `s` has a length of at most `10^4`.

The question interface includes Question, Solution, and Community tabs. The solution is locked, and the community tab shows 47 entries. Code execution is available through the editor after [sign-up](https://www.aced.io/signup?src=lesson).

## Question metadata

- **Roles with reported interviews:** [Software Engineer](https://www.aced.io/questions?role=swe) — 12; [Data Scientist](https://www.aced.io/questions?role=data-science) — 3; [Data Engineer](https://www.aced.io/questions?role=data-engineer) — 2; QA Engineer; Machine Learning Engineer.
- **Companies with reported interviews:** [Apple](https://www.aced.io/questions?company=apple) — 2; [Meta](https://www.aced.io/questions?company=meta-facebook) — 2; [Amazon](https://www.aced.io/questions?company=amazon) — 2; Roblox; MongoDB; ServiceNow; Netflix; Booking.com; TikTok; Intel; LinkedIn; Salesforce; Spotify; Oracle; Goldman Sachs; Bloomberg.

## Interview experiences

Six shared interview experiences appear with this question. These are candidate reports, not results from our own interview process.

- [Apple — Software Engineer interview, a month ago](https://www.aced.io/experiences/apple-software-engineer-interview-b4e1d1): “The interviewers were really nice and guided me though the questions. for the coding part I managed to find the optimal solution, for the sys design they walked me through”
- [Roblox — Software Engineer, Senior / L5, 5 months ago](https://www.aced.io/experiences/roblox-senior-software-engineer-interview-8f09cc): “Fairly standard interview process, recruiters are very helpful in giving general direction of how to prepare for each interview”
- [MongoDB — Software Engineer, Entry Level / L3, 7 months ago](https://www.aced.io/experiences/mongodb-software-engineer-interview-e58ddc): “I think I did pretty decently overall, though I felt there was definitely room for improvement. The technical questions were very appropriate for an Entry Level SWE role, and you could arrive at coherent answers by practicing the 150 Neetcode questions, and using proper application from DSA classes. Though the hiring manager interview at the end was stranger, as it focused more on just general problem solving / knowledge questions as opposed to a full-on behavioural. The behavioural questions I felt I could've done better, mostly because I was unprepared for it and should have spent more time making my responses more coherent.”
- [Amazon — Software Engineer, Mid Level / L4, 2 years ago](https://www.aced.io/experiences/amazon-software-engineer-interview-7eac4b): “There is not that much interaction with a recruiter. I was lucky in the coding question was not hard but they have a bank essentially similar to leetcode mediums. The bar raiser round you should prepare stories for each one”
- [Bloomberg — Software Engineer, 2 years ago](https://www.aced.io/experiences/bloomberg-software-engineer-interview-813404): “1 Phone Leetcode Onsite loop 1 LC, 1 SD, 1HR + 1 EM ( 30m each) Process seemed quite standard, the leetcode were all from top 50 tagged.”
- [Amazon — QA Engineer, Mid Level / L4, 2 years ago](https://www.aced.io/experiences/amazon-qa-engineer-interview-59ba7c): “Recruiter was super helpful throughout the process helping me navigate through the process and super responsive whenever I had any questions. Lot of interesting questions asked to test problem solving + LPs related questions can sometimes put you on spot in revealing things that you don't want to. Overall it was a good experience and recruiter reached out to me after a week.”

## Related questions

- [Longest Valid Parentheses](https://www.aced.io/questions/7102/find-longest-valid-parentheses)
- [Generate Parentheses](https://www.aced.io/questions/1594/generate-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, including ML system design, core concepts, coding, and behavioral interviews, to help candidates prepare for machine-learning roles at Meta, Google, Amazon, Apple, Microsoft, Nvidia, and other 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 for data-science roles at Google, Amazon, Microsoft, Meta, Apple, and other companies.

You can also browse [all questions](https://www.aced.io/questions).

---

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