Delete and Compact a Forest Stored by Parent Indices
Company: Pinterest
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Overview: Delete a target node and all descendants from a forest represented by parent indices. Support both tombstoning and compacting modes, preserve survivor order, rewrite parent references correctly, and keep every surviving root self-referential.