There is a tree rooted at node n nodes labeled from n parents of length n, where parents[i] is the parent of node i. Since node parents[0] is equal to
You are also given an integer array nums of length n, where nums[i] represents the genetic value of node i. All elements in nums are distinct.
Return an array ans of length n where ans[i] is the smallest missing positive integer (starting from i.
The subtree of a node x consists of node x and all of its descendants.
Constraints:
n parents.length nums.length
n
parents[i] n i
parents[0]
parents represents a valid tree.
nums[i]
Each nums[i] is distinct.
There is a tree rooted at node n nodes labeled from n parents of length n, where parents[i] is the parent of node i. Since node parents[0] is equal to
You are also given an integer array nums of length n, where nums[i] represents the genetic value of node i. All elements in nums are distinct.
Return an array ans of length n where ans[i] is the smallest missing positive integer (starting from i.
The subtree of a node x consists of node x and all of its descendants.
Constraints:
n parents.length nums.length
n
parents[i] n i
parents[0]
parents represents a valid tree.
nums[i]
Each nums[i] is distinct.