Question: Handwon P . Nodes Reordering You are given a tree which consists of N nodes and an array A where A [ U ] represents

Handwon
P. Nodes Reordering
You are given a tree which consists of N nodes and an array A where A[U] represents the value of nodele U
You are also given an array P where the parent of node U is given by P[U].
We say that the path from U to V is considered good if for each pair of adjacent nodes [i, j]. the values written on these nodes satisfy the following condition:
A[i] A A[j] is smaller than both A[i] and A[](where A is the bitwise xor operator)
Find the maximum length of a good path that you can get.
Note:
it is given that P[1]=0
 Handwon P. Nodes Reordering You are given a tree which consists

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!