Mark and Compact a Heap-Indexed Subtree

Quick 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.

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.

|Home/Coding & Algorithms/Pinterest
Pinterest logo
Pinterest
Jul 2, 2026
mediumSoftware EngineerOnline AssessmentCoding & Algorithms
7
0
Loading...

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...