Delete a Forest Subtree and Compact Parent Indices
You are given a forest with n nodes labeled from 0 to n - 1. In the array parent:
parent[i] = -1means nodeiis a root.- Otherwise,
parent[i]is the index of nodei's parent.
The...
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Standard Input
Execution Result:
