Mark and Compact a Heap-Indexed Subtree
Company: Pinterest
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Online Assessment
Overview: In a dense heap-indexed binary tree array, mark a target node and all indexed descendants with -1, then stable-compact the survivors. Return separate marked and compacted arrays, validate reserved values and uniqueness, and never mutate the input.