Reported March 2024
Googlestack

Is Balanced String

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

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

Google's 'Is Balanced String' problem showed up in March 2024, and it's testing whether you can spot a classic bracket-matching pattern fast. You're under time pressure, your hands are shaking, and you need to either nail the solution or have a backup. This is a string validation problem that rewards pattern recognition over brute force. StealthCoder reads the problem live and feeds you the move if you blank mid-interview.

Pattern and pitfall

The problem is asking you to validate that some string (likely with brackets, parentheses, or braces) follows valid nesting rules. The trick isn't complexity; it's choosing the right data structure. A stack solves this cleanly: push opening symbols, pop and match on closing symbols. If the stack empties cleanly at the end, it's balanced. If you mismatch or the stack has leftovers, it's not. Common pitfall: trying to count characters instead of tracking nesting depth. Google asks this to see if you reach for the right tool immediately. StealthCoder's value here is catching the pattern name so you don't waste 10 minutes on a greedy or two-pointer false start.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Is Balanced String 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. If you're reading this with an OA window open, you're who this was built for.

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 Google's OA.

Google reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Is Balanced String FAQ

Is this just checking if parentheses are balanced?+

Likely yes, but the input may have mixed bracket types or extra characters. The core is always the same: opening and closing symbols must nest correctly and match by type. A stack handles all cases.

What's the gotcha?+

Candidates often try character-counting or position-tracking first. Both fail on mixed types. The stack approach is 10 lines and bulletproof. Don't overthink it.

How do I code this in under 2 minutes?+

Iterate once. For each char, push if opening, pop and compare if closing. At the end, check the stack is empty. Use a simple map to store matching pairs. Done.

What if there are extra characters or spaces?+

Skip non-bracket characters. Only push/pop on brackets. Extra stuff between valid pairs doesn't matter. The stack still works.

Can I do this without a stack?+

Recursion or a counter work for single bracket types, but a stack is cleaner and scales to mixed types. Google likes the stack solution because it generalizes.

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

OA at Google?
Invisible during screen share
Get it