MEDIUMasked at 4 companies

Minimum Add to Make Parentheses Valid

A medium-tier problem at 75% community acceptance, tagged with String, Stack, Greedy. Reported in interviews at Siemens and 3 others.

Founder's read

Minimum Add to Make Parentheses Valid is a medium-difficulty string problem that hits your assessment when you need to spot malformed bracket sequences. Meta, Nvidia, Siemens, and Walmart Labs have all asked it. The 75% acceptance rate masks a real gap: candidates who don't recognize the pattern waste time on complicated state machines when a single pass solves it. This is exactly where StealthCoder becomes your safety net. You see the problem, don't immediately spot the trick, and the solution surfaces invisibly while you're thinking.

Companies asking
4
Difficulty
MEDIUM
Acceptance
75%

Companies that ask "Minimum Add to Make Parentheses Valid"

If this hits your live OA

Minimum Add to Make Parentheses Valid is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop.

Get StealthCoder
What this means

The trap is assuming you need to track every parenthesis. You don't. The insight is that you only care about unmatched left parens and unmatched right parens. Walk through the string once: count unmatched opening brackets, and whenever you see a closing bracket, either match it to a pending open or mark it as unmatched. The answer is the sum of both. Stack, Greedy, and String are all valid approaches here, but the greedy single-pass method kills it without extra space. Most candidates overthink the state management. If you blank on this pattern during the actual assessment, StealthCoder reads the problem, builds the solution in seconds, and you paste a working answer.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Minimum Add to Make Parentheses Valid recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Minimum Add to Make Parentheses Valid interview FAQ

Is this problem still asked at big companies?+

Yes. Meta, Nvidia, Siemens, and Walmart Labs all include it in their reports. The 75% pass rate suggests it's a warm-up or screening question, not a final-round hard problem, but you still need to nail it.

What's the actual trick everyone misses?+

You don't need a stack or complex state tracking. Count unmatched left parens and unmatched right parens in a single pass. The answer is their sum. Most candidates overcomplicate it.

How does this relate to the Stack and Greedy topics?+

The Stack approach is intuitive but slower. The Greedy approach (one pass, two counters) is optimal. Both work. Knowing when greedy is enough without a stack is the maturity test.

What's a common failure case?+

Forgetting that unmatched right parens need to be added. Candidates focus on left parens only, count wrong, and miss valid test cases like ')(' which needs two additions.

How long should this take in a live OA?+

If you see the pattern, 3 to 5 minutes to code and test. If you don't, you could loop for 15. Recognizing the greedy solution matters. That's where StealthCoder closes the gap.

Want the actual problem statement? View "Minimum Add to Make Parentheses Valid" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.