Can someone please help me with this question?

Revision en1, by _idgaf_, 2021-09-20 15:26:29

Given a tree with N nodes, each node has some value assigned to it. The tree is rooted at node 1 (1-based indexing). For each node, find number of ancestors with value greater than current node. 1<=N<=70000 0<=Value of node<=1e9

eg: N=5 value = [5,4,3,2,1] (remember 1 based indexing) edges = [[1,2],[2,3],[3,4],[4,5]]

Output: [0,1,2,3,4]

Tags tree

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English _idgaf_ 2021-09-20 15:26:29 394 Initial revision (published)