Two Sigma, as a top-tier Quant Fund, has always set the industry standard for interview difficulty. The recently leaked OA (Online Assessment) gives 120 minutes to complete 2 algorithm problems.
Many students think: "Two hours for two problems? That's way too generous!"
Don't be fooled. Two Sigma problems often have lengthy descriptions, complex business logic, and numerous corner cases. The generous time is given because the problems truly require you to spend time "nitpicking the details."
Our oavoservice team got the actual problems immediately and will break down the "hidden traps" in these two questions.
🔍 Problem 1: IPO Share Allocation
Core Problem: Simulate the bidding and allocation process of stock IPO.
Bidding Rules: Users submit (id, shares, price, timestamp).
Allocation Logic: Priority goes to highest bidders.
Key Difficulty: What if multiple people bid the same highest price and remaining shares are insufficient?
The rule is Round Robin: Within the same price group, sort by timestamp, give each person 1 share first, cycle through until everyone gets enough or shares run out.
Output: Return all unlucky user IDs who got zero shares, sorted in ascending order.
oavoservice Exclusive Analysis:
This problem disguises itself as "business logic" but actually tests complex simulation + multi-level sorting.
Trap 1 (Round Robin): Many students directly sort by timestamp then allocate all at once - this is wrong! The problem requires "one share per person in rotation."
This means if 3 shares remain with 2 people, A wants 10 shares, B wants 10 shares:
- Round 1: A gets 1, B gets 1 (1 share left)
- Round 2: A gets 1 (allocation complete)
Result: A gets 2 shares, B gets 1 share. Not A directly getting 2 shares, B getting 1 (though result looks same, logic differs completely if A only wanted 1 share).
Trap 2 (Data Structure): Need PriorityQueue or custom Comparator for multi-level sorting of Bids (Price DESC -> Timestamp ASC).
Solution Approach:
- Group Bids by Price
- Start from highest price group, if group's total demand <= remaining shares, satisfy directly
- If group's total demand > remaining shares, enter while loop to simulate Round Robin allocation
- Record all users who got >0 shares, then find difference with total user set
🔍 Problem 2: Sewer Drainage System
Core Problem: Given a tree-structured drainage system, parent[i] means water flows from i to parent[i]. input[i] is the inflow at that node.
Task: Cut one edge to split the tree into two parts, minimizing the absolute difference in total flow between the two parts.
oavoservice Exclusive Analysis:
This is a classic Tree DP / DFS problem.
Model Transformation: Although the problem mentions water flowing to root, cutting an edge essentially separates node u and all its child nodes (Subtree).
Mathematical Derivation:
- Let total tree flow = TotalSum
- Let subtree flow when cutting edge between node i and its parent = SubtreeSum[i]
- Then the other part's flow = TotalSum - SubtreeSum[i]
We need to minimize: | (TotalSum - SubtreeSum[i]) - SubtreeSum[i] |
Which is: | TotalSum - 2 * SubtreeSum[i] |
Solution Approach:
- Build Graph: Construct Adjacency List from parent array, note that problem gives "child points to parent", we need "parent points to child" for DFS
- Calculate Total Flow: Sum input array to get TotalSum
- DFS Post-order Traversal: Bottom-up calculation of each node's SubtreeSum (including own input + all child nodes' SubtreeSum)
- During calculation, apply formula
| TotalSum - 2 * SubtreeSum |to update global minimum
Complexity: Time O(N), Space O(N)
💡 Why Do People Still Fail With 120 Minutes?
Though these problems don't use obscure algorithms, under high pressure:
- Problem 1's Round Robin simulation easily leads to Infinite Loops or index out of bounds
- Problem 2's tree building process is error-prone (handling Parent array)
- Two Sigma's Test Cases have extensive coverage, slight carelessness leads to Runtime Error
If you're preparing for algorithms and system design interviews at Two Sigma, TikTok, Google, Amazon and other big tech companies
Or feeling uncertain about OAs: Welcome to contact us!
We aim not just to "get it right," but to "pass with full marks."
✅ OA Ghostwriting / Test Guarantee: Covering top Quant firms like Two Sigma, Citadel, JS and various Tech giants
✅ Algorithm Interview Assistance: Real-time solutions for Hard difficulty Coding problems
✅ Stable, Safe, Efficient: Long-term practical experience to help you land offers soon
👉 Add WeChat immediately: Coding0201
Get the latest big tech OA problem sets & free consultation service!