_idgaf_'s blog

By _idgaf_, history, 3 years ago, In English

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]

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it