Two Sigma logo

Two Sigma Hard Interview Questions

4 hard-level practice questions for Two Sigma technical interviews

Two Sigma software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer
coding Hard Verified Question #1

1. Concert Ticket Auction


Category: Algorithm coding problem

Question A venue is holding an auction to allocate a limited number of concert tickets to fans. Before the sale closes, fans can submit bids. Each...

Input: List
Output: Computed result
coding Hard Verified Question #2

2. Pipeline Throughput Optimizer


Category: Array coding problem

Question A message-processing pipeline consists of n services that must all be traversed in sequence. The pipeline's effective throughput is...

Input: Array
Output: Integer
coding Hard Verified Question #3

3. Non-Adjacent Team Selection


Category: Tree coding problem

Question You are given n people labeled from 0 to n - 1. Some pairs of people know each other directly. These relationships are given as a...

Input: List
Output: Computed result
coding Hard graph #1

1. [Graph] — Find shortest path in a weighted graph


Background: Two Sigma often deals with large datasets and requires efficient algorithms for data processing and analytics. Finding optimal paths in graphs can significantly enhance data-related tasks, such as trading algorithms and routing.
Problem statement: Given a weighted directed graph represented as an adjacency list, write a function shortest_path that finds the shortest path from a starting node to a destination node using Dijkstra's algorithm. You should return the path as a list of node identifiers and the total weight of that path.
Function/class signature:
  • def shortest_path(graph: Dict[int, List[Tuple[int, int]]], start: int, end: int) -> Tuple[List[int], int]:


Example 1:
  • Input: graph = {0: [(1, 4), (2, 1)], 1: [(3, 1)], 2: [(1, 2), (3, 5)], 3: []}, start = 0, end = 3

  • Output: ([0, 2, 1, 3], 5)

  • Explanation: The path 0 -> 2 -> 1 -> 3 has a total weight of 5.


Example 2:
  • Input: graph = {0: [(1, 10), (2, 5)], 1: [(3, 2)], 2: [(1, 3), (3, 1)], 3: []}, start = 0, end = 3

  • Output: ([0, 2, 3], 6)

  • Explanation: The path 0 -> 2 -> 3 has a total weight of 6.


Constraints:
  • The number of nodes in the graph will not exceed 10^5.

  • The edges' weights are positive integers.

  • You can assume the graph is connected and directed.


Start practicing Two Sigma questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free