Quick Overview

Reconstruct an ordered rooted tree from preorder text in which hyphen count encodes depth and values may have multiple digits. Return a canonical nested-tuple representation while handling arbitrary child counts and long valid inputs without evaluating generated code.

Recover a Rooted Tree from Depth-Annotated Preorder

Company: Grammarly

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Technical Screen

Overview: Reconstruct an ordered rooted tree from preorder text in which hyphen count encodes depth and values may have multiple digits. Return a canonical nested-tuple representation while handling arbitrary child counts and long valid inputs without evaluating generated code.

Loading…