Reported July 2026
Squarepoint Capitalstack

Evaluating Circuit Expressions

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

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

Squarepoint Capital reportedly asked this one in July 2026, and the naive version dies on the size limit, not the logic. Each expression can run up to 10^6 characters, so deep nesting will wreck a recursive parser. It's a bracketed boolean expression evaluator: operator first, then comma-separated operands, each either 0, 1, or another bracket. If you've got an OA coming, this is a stack problem wearing a parsing costume. StealthCoder is the safety net if you freeze on the live OA, but the idea is short enough to hold in your head.

The problem

Given a list circuitsExpression of valid circuit-expression strings, evaluate every expression and return its circuit value.
A circuit expression uses the following symbols:
[ and ] group an operation and determine precedence.
& denotes logical AND.
| denotes logical OR.
! denotes logical NOT.
1 denotes logical true.
0 denotes logical false.
Every bracketed expression places its operator first:
[!, x] evaluates to NOT x.
[&, x, y] evaluates to x AND y.
[|, x, y] evaluates to x OR y.
An operand may be 0, 1, or another bracketed expression. Commas separate entries, and whitespace may appear between tokens.
Return a list of integers containing the value of each expression, in the same order as circuitsExpression. Every returned value is either 0 or 1.

Function
circuitsOutput(circuitsExpression: List<String>) → List<Integer>

Examples
Example 1
circuitsExpression = ["[|, [&, 1, [!, 0]], [!, [|, [|, 1, 0], [!, 1]]]]"]
return = [1]
Evaluate the innermost operations first. The left branch is 1 AND NOT 0 = 1. The right branch is NOT ((1 OR 0) OR NOT 1) = NOT 1 = 0. The outer OR therefore evaluates to 1 OR 0 = 1.
Example 2
circuitsExpression = ["[!, 1]","[&, [|, 1, 0], [!, 0]]","[|, [&, 1, 0], [!, 1]]"]
return = [0,1,0]
The three expressions evaluate independently: NOT 1 = 0, (1 OR 0) AND NOT 0 = 1, and (1 AND 0) OR NOT 1 = 0.
Example 3
circuitsExpression = ["[!, [!, [!, 0]]]","[|, [&, 1, 1], [!, [|, 0, 1]]]"]
return = [1,1]
Three consecutive NOT operations applied to 0 produce 1. In the second expression, the left operand is 1, so the outer OR is also 1.

Constraints
The total number of expressions is less than 10.
Each expression contains no more than 10^6 characters.
Every expression is valid and contains only 0, 1, [, ], &, |, !, commas, and whitespace.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is an explicit stack instead of recursion. Scan characters, skip whitespace and commas. On '[' do nothing special, on an operator push a marker for it, on 0 or 1 push the value. On ']' pop operands until you hit the operator marker, apply it, and push the result. The edge case that breaks naive solutions is depth. A string of 10^6 characters can nest hundreds of thousands of levels, so recursive descent blows the call stack in most languages. Second pitfall: NOT takes one operand, while AND and OR may be handed more than two if you pop until the marker, so fold them rather than assuming exactly two. Whitespace between tokens also trips up split-on-comma shortcuts. Linear time, linear space. If the stack logic slips under pressure, StealthCoder can cover you during the live OA.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Evaluating Circuit Expressions 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 for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as parsing a boolean expression. If you have time before the OA, drill that.

⏵ The honest play

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

Squarepoint Capital reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Evaluating Circuit Expressions FAQ

What's the trick for Evaluating Circuit Expressions?+

Use an explicit stack. Push operators and values as you scan, and when you hit a closing bracket, pop operands back to the operator, compute, and push the result. It's one pass, so it runs in linear time even at 10^6 characters.

Why does recursion fail here?+

Expressions can be up to 10^6 characters, so nesting can get extremely deep. Recursive descent can overflow the call stack in many languages. An iterative stack avoids that entirely and is just as simple to write.

How should I handle whitespace and commas?+

Skip them while scanning character by character. Don't split on commas, because nested brackets contain commas too and splitting breaks the structure. Only 0, 1, &, |, !, [ and ] carry meaning for the evaluator.

Do AND and OR always have two operands?+

The examples show two, but safest is to pop everything back to the operator marker and fold. That handles any operand count. NOT just reads the single value. It costs nothing extra and removes a whole class of bugs.

How do I prepare for this in 48 hours?+

Write the stack evaluator once from scratch, then test three cases: triple NOT, deeply nested brackets, and extra whitespace. Also confirm you return results in input order as a list of integers. That covers what Squarepoint Capital reportedly tested.

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

OA at Squarepoint Capital?
Invisible during screen share
Get it