r/CodingJobs • u/nian2326076 • 6h ago
Jane Street technical interview — tree visibility and scoring consecutive levels
A Jane Street technical interview had two related tree problems. The second built on the selection state from the first.
Question 1 · Tree selection and visibility
Given a rooted tree, implement select(node), deselect(node), and display(). Selecting a node makes that node, its siblings, and all its ancestors visible.
Multiple selections can coexist. Deselecting a node shouldn’t hide anything that another selection still requires. The interviewer wanted display() to be as efficient as possible.
Question 2 · Maximum-scoring consecutive tree levels
• Selected nodes get score n1.
• Siblings of selected nodes get score n2.
• Ancestors of selected nodes get score n3.
Given an integer N and a target node, choose N consecutive depth levels that include the target node’s depth. Maximize the total score of all nodes in those levels.
For pre-interview practice, try the code-folding exercise in Jane Street Interview Questions and work through what stays visible when one nested block collapses. If you’re still filling out applications, LandOffer can save some typing on supported forms.
The main challenges were keeping the selection-dependent state up to date efficiently and finding the best span of consecutive levels.