Maximum Path sum in tree

Revision en3, by vrkorat211, 2020-08-23 11:48:59

Question asked in Google online coding challenge on 22nd AUG, 2020.

Please help me with this question.

You are given a tree with N nodes numbered 1 to N. Each node is having weight Ai. (1 <= i <= N)

Find the maximum path sum between any two node u and v of the tree. Return the maximum path sum value. constraints:

1 <= T <= 10
1 <= N <= 1e4
-1e6 <= Ai <= +1e6

Example:

Tags #trees, path-sum, #help

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English vrkorat211 2020-08-23 11:48:59 14 Tiny change: 'e coding competition on 22nd A' -> 'e coding challenge on 22nd A'
en2 English vrkorat211 2020-08-23 11:47:58 16
en1 English vrkorat211 2020-08-23 11:46:18 781 Initial revision (published)