Back to problems

Limit Tree Height by Deletions

Algorithm · Snowflake · Hard

Problem You are given an N-ary tree in which every node has an integer id and a list of child nodes. Given a list of node ids to delete, compute the height of the tree after all deletions have been applied. When a node is deleted, its children are promoted into that node's former position: they become direct children of the deleted node's parent, as if the node were unlinked from a chain while keeping the remaining chain connected. Height is the number of nodes on the…

Checking your access…