Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Can someone please help me with this question?

Правка en1, от _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]

Теги tree

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский _idgaf_ 2021-09-20 15:26:29 394 Initial revision (published)