Reported September 2026
Oraclestack

Valid Parentheses

Reported by candidates from Oracle's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Oracle OA. Under 2s to a working solution.
Founder's read

The edge case that kills the naive solution on this Oracle OA, reported in September 2026, is counting brackets instead of tracking order. Candidates tally opens and closes, see equal numbers, and return true on "([)]". That's wrong. This is Valid Parentheses, a stack problem, and the input can be empty or 100000 characters long. If you blank when the clock is running, StealthCoder runs invisibly on your desktop as a safety net and gives you the solution live. Know the stack idea cold anyway, because it takes ten lines.

The problem

Given a string s containing only the bracket characters (, ), [, ], {, and }, determine whether it is valid.
A string is valid when every opening bracket is closed by the same type of bracket and brackets close in the reverse order in which they were opened. The empty string is valid.
Return true if s is valid; otherwise, return false.

Function
isValidParentheses(s: String) → boolean

Examples
Example 1
s = "()[]{}"
return = true
Each opening bracket is immediately followed by its matching closing bracket.
Example 2
s = "([{}])"
return = true
The brackets are properly nested and close in reverse opening order.
Example 3
s = "([)]"
return = false
The closing parenthesis appears before the nested square bracket is closed.

Constraints
0 <= s.length <= 100000.
Every character of s is one of ()[]{}.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Push every opening bracket onto a stack. On a closing bracket, the stack must be non-empty and its top must be the matching opener. Pop it. If not, return false immediately. At the end, return true only if the stack is empty. Three pitfalls show up. First, counting per bracket type passes "([)]" and fails the order rule. Second, popping from an empty stack on input like ")" throws or misbehaves. Third, forgetting the final empty check returns true for "(((". The empty string returns true naturally. With 100000 characters, O(n) time and O(n) space is fine, and you can bail early if the length is odd. A map from closer to opener keeps the code short. If your mind goes blank mid-assessment, StealthCoder is the hedge that surfaces this exact pattern while you keep typing.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Valid Parentheses cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as valid parentheses. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Oracle's OA.

Oracle reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Valid Parentheses FAQ

How hard is Valid Parentheses really on the Oracle OA?+

It's easy if you recognize the stack. The whole solution is a single pass with push and pop. The difficulty is in the edge cases: a lone closing bracket, leftover openers, and the empty string. Get those three right and you're done in minutes.

What's the trick to this problem?+

Brackets must close in reverse order of opening, which is exactly last in, first out. That's a stack. Push openers, and on each closer check that the top matches. Counting characters can't capture order, so it fails on "([)]".

Which edge cases should I test before submitting?+

Test the empty string (true), a single closer like ")" (false, empty stack), a single opener like "(" (false, leftover), "([)]" (false, wrong order), and a long nested string. Also confirm you check the stack is empty at the end, not just during the loop.

Is the stack pattern still asked in OAs?+

Yes. Bracket matching is a staple because it's quick to write and easy to grade. Oracle reported it in September 2026. Expect variants too, like minimum insertions to balance or longest valid substring, which build on the same stack idea.

How do I prepare for this in 48 hours?+

Write the solution from scratch twice without looking. Use a map of closer to opener, an early return on empty stack, and a final empty check. Then run the four edge cases by hand. That's enough. Spend the rest of your time on the other problems likely in the set.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Oracle.

OA at Oracle?
Invisible during screen share
Get it