InterviewLegend

The Two Sigma Online Assessment

Alex Chen40 min readGuide updated
In this lesson
  • Know the format, scoring and AI rule of the Two Sigma SWE online assessment
  • Solve the IPO share allocation with a timestamp sort and a true round robin
  • Split the drainage tree with one subtree-sum pass that never recurses
  • Practice the two rarer OA problems once the main pair is solid

Most Two Sigma software engineering loops open with an online assessment, usually after the recruiter call. The format is two problems that share one timer, and a current job posting says you must pass the company's required skills assessment. It also barely changes. Candidates in October 2021 described an IPO share allocation and a tree split. Candidates in 2025 and 2026 describe the same two, by name.

The format and the rules come first. Then both problems get worked in runnable Python, with the traps real candidates fell into. Two rarer OA problems come last. Give them an hour once the main pair feels easy. The research and PhD intern OAs are a different test, and they have their own lesson.

The Two Sigma angle
Two Sigma rarely changes these two questions, so the bar is a clean pass. When nearly everyone has seen the IPO and drainage problems, a half-working answer stands out for the wrong reason. Spend your prep on edge cases and on reading the long statements quickly.

What the Two Sigma OA looks like

You get two problems and one clock, and you split the time between them however you like. A July 2026 new grad put it as two problems done together under one time limit. Candidates name HackerRank, in 2022 and again in 2026, while a couple from 2021 to 2023 got CodeSignal. Your invite names the platform you'll get.

Length is the part people get wrong. Reports from 2021 to 2023 put the OA at 75 minutes, and so does a new grad who took it in mid 2025. Two 2025 candidates had 120 minutes, so check the invite for that too. Candidates call the problems long rather than hard. A 2025 candidate said it wasn't difficult, and a 2026 candidate breezed through it. One 2023 candidate spent ten minutes just reading the statements, which is the real time sink.

Language choice is narrower than you might expect. Two Sigma's interviews run in C, C++, Java or Python, and a 2022 candidate found C# and JavaScript weren't offered on the OA. Python is the safe pick for both problems here, since neither needs anything faster.

  • Problems: two, on one shared timer.
  • Platform: HackerRank in most reports, CodeSignal in a few from 2021 to 2023.
  • Length: 75 minutes in most reports from 2021 to 2025, 120 in two from 2025.
  • Pass bar: treat a full pass on both problems as the bar.
  • AI tools: strictly prohibited.

Is the Two Sigma OA proctored?

No 2025 or 2026 candidate mentions webcam or screen monitoring on the SWE OA, which isn't the same as saying there is none. What Two Sigma does put in writing is the AI ban, and it covers the assessment and every interview after it. Write the code yourself and assume someone may read how you got there.

Is the Two Sigma OA auto-graded?

Yes. Scoring runs on test cases, and candidates talk about results in passed cases. In late 2024 an intern candidate passed every case on the first problem, missed three on the second, and still got a first interview. In June 2026, though, someone who works at Two Sigma wrote that "nowadays you do need 100% to move on", and the newest word is the one to plan around. Aim for every case on both problems.

SWE OA vs the QR OA

The quant research, data science and PhD intern pipelines send a different test. Their OAs are data and statistics work. Candidates describe a Premium question, a regression updated batch by batch, and pandas analysis of daily temperatures by town. The two share nothing with the SWE pair, so prepare for the one your invite names. One September 2025 report does have a machine learning engineer getting the SWE pair, though.

Each of the main pair has one detail that decides the score. For the IPO it's the order inside a tied price, and for the drainage tree it's computing every subtree sum in one pass. Get those two details right and the rest is careful bookkeeping.

The two problems that keep coming back

About a dozen candidates since October 2021 have described the IPO allocation and the drainage split, the newest in June and July 2026. A November 2025 candidate's tip was to prepare hash tables and DFS. That matches the pair well: the IPO groups bids by price, and the drainage tree is a traversal.

IPO share allocation

This is the longer of the two and the one people lose points on. In June 2026 a new grad forgot to sort the tied bidders by timestamp, failed tests, fixed it, and moved to the phone round the next day. In May 2025 another candidate wrote about trouble with the test cases on both problems. The shape below is something like what candidates describe: bids filled from the highest price down, a share-at-a-time round robin inside a tied price, and the ids that got nothing as the answer.

1

IPO Share Allocation

MediumSignature problem
Problem
A company is selling total_shares shares in an IPO. Each bid is [user_id, shares, price, timestamp]: the bidder wants that many shares at that price, and the timestamp says when the bid came in. Return the user ids that receive no shares at all, sorted ascending.

Shares go to the highest price first. When only one bidder sits at a price, they get what they asked for, or whatever is left if that's less.

When several bidders share a price, they're served in timestamp order, one share per bidder per turn. A bidder whose request is filled drops out of the rotation. The rotation stops when every bidder at that price is filled or the shares run out. Then the next lower price gets whatever remains.
Inputbids = [[1,5,5,0],[2,7,8,1],[3,7,5,1],[4,10,3,3]]total_shares = 18Output[4]

User 2 bids highest and takes all 7. Users 1 and 3 tie at 5 and split the other 11 one share at a time, so both get some. Nothing is left for user 4.

How this uses the pattern

Group the bids by price and walk the prices from high to low. Inside a price, sort by timestamp and serve the bidders from a queue, one share per turn, putting a bidder back while they still want more.

Write it here, or go full screen with the problem, hints and solution beside the editor.

IPO Share Allocation

Loading...
Click "Run" to execute your code
The Two Sigma angle
Most lost points come from the sort. The rotation inside a tied price follows the timestamp, and the input isn't sorted that way, so a solution that keeps input order or sorts by user id passes the easy cases and fails the tied ones. That is exactly how the June 2026 candidate lost tests the first time. The second trap is filling one bidder's whole request before the next. That reads naturally but breaks the one-share-per-turn rule, and the test with two bidders and three shares catches it.
Take it further
Large share counts. The OA has no interviewer, but the stretch worth knowing is speed when share counts get large, because the queue hands out one share per step. Inside a tied price you can hand out whole rounds at once: everyone still waiting gets the smallest remaining request, or as many full rounds as the shares allow, whichever is less. A short last round then goes to the earliest timestamps. Worked through below.

Split the drainage tree

The second problem goes by a few names in posts: drainage, sewer system, split tree. It has been paired with the IPO since 2021. A June 2026 candidate called it a lot easier than the first question and solved it with DFS subtree sums. A November 2025 new grad didn't name their problems, but said one needed a prefix-sum trick to avoid timing out. This is the likely one, since subtree sums are prefix sums on a tree.

2

Split the Drainage Tree

MediumSignature problem
Problem
A drainage network is a tree of n nodes. parent[i] is the node that node i drains into, and the root has parent[root] = -1. flow[i] is the water that enters the network at node i. The flow of a piece of the network is the sum of flow over its nodes.

Cut exactly one edge, splitting the tree into two connected pieces. Return the smallest possible absolute difference between the two pieces' flows.

n can be up to 100,000, so the answer has to come from one pass over the tree.
Inputparent = [-1,0,0,1,1,2]flow = [1,2,2,1,1,1]Output0

The total is 8. Cutting the edge above node 1 separates nodes 1, 3 and 4, which carry 4, leaving 4 on the other side.

How this uses the pattern

Cutting the edge above node v leaves its subtree on one side, so that side carries subtree_sum[v] and the other carries total minus that. Compute every subtree sum in one bottom-up pass and minimize the absolute value of total minus twice the subtree sum.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Split the Drainage Tree

Loading...
Click "Run" to execute your code
The Two Sigma angle
Each cut is fully described by the node below it, so the candidate answers are the subtree sums, and nothing more needs searching. Size matters too. At 100,000 nodes, recomputing a subtree per cut times out, and a recursive DFS in Python can hit the recursion limit on a deep chain. Build the children lists, take a BFS order from the root, and add each node into its parent in reverse order. That's iterative, linear, and safe at any depth.
Take it further
Return the edge as well as the gap. The OA has no interviewer, but naming the branch to cut is a good stretch. Keep the node with the best gap as you scan, and the edge runs from that node to its parent. Also make sure your code finds the root from the -1 instead of assuming node 0.

Two rarer OA problems

OAs from October 2025 and August 2026 had a different pair: a bracket string split with wildcards and a pixel color matcher. That's two OAs, a long way from the dozen behind the IPO and drainage problems, so treat them as possible rather than likely. They're short, and they test the same habit of counting carefully.

3

Balanced Split String With Wildcards

MediumSometimes asked
Problem
You're given a string s made of the characters (, ), [, ] and ?. A ? can stand for any one of the four brackets.

Count the ways to cut s into two non-empty parts, a prefix and a suffix, so that each part can be rearranged into a balanced bracket string. Rearranging means you may reorder a part's characters freely, then choose a bracket for each ? in it.

s can be up to 100,000 characters long.
Inputs = "(??]"Output1

Only the middle cut works. "(?" becomes "()" and "?]" becomes "[]". The other two cuts leave a part of odd length.

How this uses the pattern

Because a part can be reordered, only its counts matter. A part works when its length is even and its wildcards cover the round gap plus the square gap. Keep running counts for the prefix and the suffix and check every cut in one pass.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Balanced Split String With Wildcards

Loading...
Click "Run" to execute your code
The Two Sigma angle
Rearranging is the word that makes this easy, since a reordered part only needs the right counts. The unmatched round brackets number the absolute difference of the open and close counts, and the same goes for square ones. Wildcards must cover both gaps. Leftover wildcards then pair up as "()", which works whenever the part's length is even. Without that reduction, people try to simulate a stack per cut and run out of time at 100,000 characters.
Take it further
Drop the rearranging. If each part must be balanced as written, counts aren't enough, and you need a stack-style check with wildcards for both bracket types, which is far harder. Ask which version the statement means before you code, and look for the word rearranged.
4

Closest Pure Color

EasySometimes asked
Problem
Each pixel is a 24-character binary string. The first 8 bits are red, the next 8 green and the last 8 blue, each a value from 0 to 255.

For every pixel, find the nearest of five pure colors by straight-line distance in RGB: Black (0, 0, 0), White (255, 255, 255), Red (255, 0, 0), Green (0, 255, 0) and Blue (0, 0, 255). Return a list with that color's name for each pixel, or Ambiguous when two or more pure colors tie for nearest.
Inputpixels = ["000000000000000011111111"]Output["Blue"]

The pixel is (0, 0, 255), which is pure blue.

How this uses the pattern

Slice each string into three 8-bit pieces and parse them in base 2. Compare squared distances to the five colors, so every value stays an integer, and check whether the smallest distance is shared.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Closest Pure Color

Loading...
Click "Run" to execute your code
The Two Sigma angle
On an easy problem, two details decide the score. Compare squared distances: the square root changes nothing about which is nearest, and integer math makes ties exact. A float distance can make two equal values differ in the last digit and turn a real tie into a wrong name. Then check for a shared minimum before naming a winner, because yellow, cyan and magenta all tie three ways.
Take it further
More reference colors. If the palette grows to thousands of colors and millions of pixels, checking every color per pixel gets slow. A grid of buckets over RGB space, or a k-d tree, finds the nearest without scanning the whole palette. For five colors the plain loop is right.

How to spend the timer

Read both statements before you write anything. If you get the usual pair, the drainage split is shorter to code, and banking it first leaves the rest of the clock for the IPO's fiddly ordering. Write the IPO from the statement's rules, line by line, and run it against a tied price with shuffled timestamps before you submit.

Test the cases the samples skip. For the IPO that means zero shares, a tie that runs out mid-rotation and a lower price nobody reaches. For the drainage tree it's two nodes, a long chain and a root that isn't node 0. Each takes a minute to type. The June 2026 candidate who skipped the timestamp sort learned about it from failed tests, so find out before you submit.

Common questions

What questions are on the Two Sigma OA?

For software engineers, the IPO share allocation and the drainage tree split have been the pair since 2021, and candidates reported them again through mid 2026. A couple of OAs from October 2025 and August 2026 had a bracket split with wildcards and a pixel color matcher instead.

How long is the Two Sigma online assessment?

Most candidates had 75 minutes for the two problems, from 2021 through mid 2025. Two in 2025 had 120, so go by your invite. Plan on the statements taking real time to read.

Is the Two Sigma OA on HackerRank?

Most candidates got HackerRank, and a few from 2021 to 2023 got CodeSignal. The invite names the platform.

How soon do you hear back?

It varies. A June 2026 new grad got the email moving them to the next round the very next day. After the OA comes a live technical screen, which the process overview walks through.

Key Takeaways

  • ✓The Two Sigma SWE OA is two problems on one timer, and the IPO and drainage pair has held since 2021.
  • ✓In the IPO problem, sort each tied price by timestamp and hand out one share per turn.
  • ✓Split the drainage tree with one iterative subtree-sum pass, then minimize the gap between the total and twice each subtree.
  • ✓Aim for every test case on both problems, since a 2026 insider says a full pass is now the bar.
Two Sigma interview guide

Know what Two Sigma asks before you walk in.

21 coding · 4 system design · 13 behavioral questions

Get Premium$49 a year · Instant access
Or start freeNo card.

Get their questions first.

What Two Sigma TestsHad your Two Sigma interview?How we research

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.