Build a Top-Down Reporting Forest from Employee-Manager Pairs

Quick Overview

Given employee-to-manager pairs of integer IDs, build the top-down reporting forest with every top-level manager as a root, and return it as a preorder listing of IDs and depths. Tests finding the roots, building child lists, deterministic sibling ordering, and handling long reporting chains.

Build a Top-Down Reporting Forest from Employee-Manager Pairs

Company: Snowflake

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Overview: Given employee-to-manager pairs of integer IDs, build the top-down reporting forest with every top-level manager as a root, and return it as a preorder listing of IDs and depths. Tests finding the roots, building child lists, deterministic sibling ordering, and handling long reporting chains.

Snowflake logo
Snowflake
Sep 28, 2026
mediumSoftware EngineerOnsiteCoding & Algorithms
21
0
Loading...