Serialize Arithmetic Expression Tree with Minimum Parentheses

Asked at Waymo · Coding Questions · Difficulty: Hard · Last asked Apr 27, 2026

Write `serialize(tree)`, which turns an arithmetic expression tree into an infix string that uses as few parentheses as possible while still describing exactly the same tree. A reader (or a parser) who evaluates the string with the usual operator rules must rebuild the original structure.

Loading the problem…