Company: MediaNet_1sep
Difficulty: medium
Non-overlapping Subtrees Problem Description You are given a rooted tree with N vertices labelled from 1 to N with 1 as a root. Each vertex is assigned an integer value given by an array A. Subtree sum of any vertex v is summation of all the values of the vertices present in the subtree of v including v itself. Find two Non-overlapping subtrees such that Bitwise xor of their subtree sum is maximum, return this Maximum xor value . NOTE: Two subtrees are said to non-overlapping if they do not have any vertex in common. Return 0 if no such subtrees exists. Constraints 2 <= N <= 50000 1 <= A[i] <= 1000 1 <= B[i][0], B[i][1] <= N Input Format First argument is an integer array A of size N denoting the values assigned to the vertices. Second argument is an 2D integer matrix B of size (N - 1) x 2 where B[i][0], B[i][1] represents an undirected edge between node B[i][0] and B[i][1]. NOTE: Array A is given to you as 0-indexed but A[0] represents value of node 1 similarly for e