 Maximum path sum from any node
##### Submissions: 2156   Accuracy: 38.89%   Difficulty: Medium   Marks: 4

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.

Input:
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.

Output:
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.

Constraints:
1 <= T <= 100
1 <= N <= 103

Example:
Input:

2
6
10 2 L 2 20 L 2 1 R 10 -25 R -25 3 L -25 4 R
3
10 2 L 10 5 R 5 -2 R

Output:
32
17

Explanation:
Testcase 2:
Path in the given tree goes like 2, 10, 5, which gives the max sum as 17.

#### ** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Ayush Govil
Author: Ayush Govil 1

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.