Two Sigma OA Interview Experience | HackerRank Three Questions Passed
I recently completed Two Sigma OA Questions on the HackerRank platform. The three questions were of a decent level — more reasonable compared to TikTok or Amazon. I spent about 40 minutes and passed all test cases. Having done many big-tech OAs before, I felt quite comfortable this time.
Two Sigma’s OA focuses on engineering implementation and statistical modeling with comprehensive coverage. Below, I share the detailed problem descriptions, my solution approaches, personal reflections, and preparation tips for those preparing for Two Sigma or other quant/fintech OAs.
Problem 1: Linear Interpolator
Problem Description Given n points (x_knots, y_knots), implement a linear interpolation function. When the input x is within the range of the knot points, perform piecewise linear interpolation. When x is outside the range, perform extrapolation. Handle duplicate x values by merging them.
Solution Approach I first sorted the points by x-coordinate and merged any duplicate x values (keeping the last y). Then I used binary search to find the interval where the input x falls. If x exactly matches a knot, I returned the corresponding y. Otherwise, I built a straight line using the two neighboring points and calculated the interpolated value. For out-of-range x, I extrapolated using the nearest interval. The time complexity is dominated by sorting O(n log n) plus O(log n) per query, which is efficient even for n up to 200,000.
Personal Reflection This problem tested careful boundary handling, especially for duplicates and extrapolation. I added comments during coding to remind myself of the sorting and edge cases, and it passed all test cases smoothly.
Problem 2: Daily Temperature By Town
Problem Description Given daily temperatures for multiple towns and NYC, answer several statistical questions: the place with the largest temperature variation, median NYC temperature under certain conditions, univariate regression coefficients, best single/double variable combinations, and greedy selection of 5 towns to predict NYC temperature.
Solution Approach I handled this question module by module. For Q1, I used standard deviation to find the column with the largest variation. For Q2, I filtered the data where Town2 was between 90 and 100, then calculated the median NYC temperature. Q3 summed the absolute values of univariate regression coefficients. Q4 and Q5 iterated through single and double variable combinations to find the ones with the smallest MSE. For Q6, I used greedy forward selection, adding the feature that most reduced the current model’s MSE each round until selecting 5 features. The overall logic was clear, with careful attention to data cleaning and edge cases.
Personal Reflection This question had a lot of information, so it was easy to spend too much time on statistics. Breaking each Q into separate functions and combining them at the end greatly improved debugging efficiency.
Problem 3: Efficient Regression V5
Problem Description Implement the regression coefficient beta (no intercept) between asset returns X and Y, supporting both batch computation and streaming online updates.
Get Interviewshow-Etesiselay’s stories in your inbox
Join Medium for free to get updates from this writer.
Solution Approach For batch computation, I calculated sum_xy and sum_xx for each pair of columns, then beta = sum_xy / sum_xx. For online updates, I maintained cumulative sum_xy and sum_xx. Every time a new batch arrived, I updated the accumulators and recalculated beta. This approach efficiently supports both batch and streaming data with good time and space complexity.
Personal Reflection The key was understanding the idea of online updates. I used two dictionaries to store the cumulative sums, keeping the code clean and easy to explain if the interviewer asked follow-ups.
Overall Summary & Preparation Tips Two Sigma’s OA this time was reasonably challenging. Problem 1 tested interpolation and boundary handling, Problem 2 focused on statistical calculations and greedy optimization, and Problem 3 examined efficient regression with online updates. I was able to finish quickly mainly because I had practiced similar problems before and was familiar with the common patterns.
Suggestions for Two Sigma candidates:
- Pay attention to duplicate points and extrapolation in linear interpolation
- Master median, standard deviation, and regression coefficient calculations for statistical questions
- Focus on maintaining cumulative variables for online update problems
- Familiarize yourself with HackerRank input/output and large number handling in advance
Final Thoughts Two Sigma OA has a solid amount of questions and difficulty, especially the statistical modeling and online update parts. Without systematic practice beforehand, it’s easy to get stuck on time during the test.
During my preparation, I used Interview Aid for OA assistance. Their North American CS experts helped me organize ideas for regression models, linear interpolation, and greedy optimization in real time. The support was very effective, and I ultimately passed successfully.
If you’re also preparing for Two Sigma or other quant companies and time is tight, getting professional assistance early can save a lot of effort. Feel free to share your experiences in the comments if you’re targeting similar roles!







