PinterestCodingMembers
Tree-Encoded Subtree Deletion and Stable Compaction
Members only
A forest is stored as a parent-index array where node `i` is a root when `parent[i] == i`. First mark a target node and every descendant with `-1`; then compact the survivors to the front in stable or...
SWE
array
tree
dfs
hashmap
medium
Frequency
Low
Last asked
2026-08-26
Stage
phone-screen
Log in to continue reading the full content
Comments
Sign in to join the discussion
Loading...
