Given a binary tree of N edges, where every node contains distinct data. The task is to find the maximum path sum. The path may start and end at any node in the tree.
First line of input contains number of testcases T. For each testcase, there will be two lines, first of which containing the number of edges (between two nodes) in the tree. Next line contains N pairs (considering a and b) with a 'L' (means node b on left of a) or 'R' (means node b on right of a) after a and b.
Print the maximum path sum in the binary tree.
The task is to complete the findMaxSum that takes root as input and returns max sum.
1 <= T <= 100
1 <= N <= 103
10 2 L 2 20 L 2 1 R 10 -25 R -25 3 L -25 4 R
10 2 L 10 5 R 5 -2 R
Testcase 2: Path in the given tree goes like 2, 10, 5, which gives the max sum as 17.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.