Jane Street Interview
I had a technical interview with Jane Street involving two related tree problems.
Question 1: Tree Selection and Visibility
Given a rooted tree, implement three operations:
select(node)deselect(node)display()
Selecting a node makes the node itself, its siblings, and all its ancestors visible. Multiple selections can coexist, and deselecting a node should not remove visibility that another selection still requires.
The interviewer wanted display() to be as efficient as possible.
Question 2: Maximum-Scoring Consecutive Tree Levels
The second problem extends the first. Each node receives a score based on its relationship to selected nodes:
- Selected nodes receive score
n1. - Siblings of selected nodes receive score
n2. - Ancestors of selected nodes receive score
n3.
Given an integer N and a target node, select N consecutive depth levels that include the target node and maximize the total score of nodes in those levels.
The main challenges involved maintaining selection-dependent tree state efficiently and optimizing over consecutive levels.


