The first Jane Street MLE Intern onsite coding round was the same style of general coding interview used for SWE candidates. The interviewer did not initially seem aware that I was interviewing specifically for MLE, and the problem itself contained no machine learning component.
The question was a multi-part code-editor problem involving matching braces, folding and unfolding blocks, and preserving the folded state of nested blocks.
Interview Details
Part 1 — Match Opening and Closing Braces
You are building a code editor that supports code folding. The source code is represented as list[str], with one string per source line.
The input follows several assumptions:
Braces are balanced and properly nested.
Every brace is structural.
Each line contains at most one brace, appearing as the final non-whitespace character.
A closing-brace line contains only indentation followed by }.
Line indices are zero-based and always refer to the original source.
Folding changes only the displayed output; the original source never changes.
The input may be empty.
Implement match_braces(lines) -> dict[int, int]. The returned mapping should associate every opening-brace line with the line containing its matching closing brace.