Back to problems

Forest Parent Array Delete Node

Algorithm · Snowflake · Medium

Requirements You receive a forest encoded as an array named parent. For each node at index i, parent[i] identifies that node's parent index. A node is a root when it points to itself, so roots satisfy parent[i] == i. The input is guaranteed to be valid and contains no NULL or None values. Remove the node at delete_index and return the updated parent array. After removal, the array must describe a valid forest using the new, compact set of indices. Before implementing the…

Checking your access…