← 返回 google 的题目列表Tree Node and Subtree Deletion by Index
类型:online_judge
google
Given a tree in the form of parent index and value, tree = [(-1, 'a'), (0, 'b'), (0, 'e'), (1, 'c'), (1, 'd'), (2, 'f'), (2, 'g')].
Delete the node at the given index.
Delete the entire subtree of the node at the given index.
Example
Input
tree = [(-1, 'a'), (0, 'b'), (0, 'e'), (1, 'c'), (1, 'd'), (2, 'f'), (2, 'g')]
index_to_delete = 1