BETA

Submissions : 160 Accuracy :

40.63

Maximum path sum from any node (Function Program)
     

Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. Every node contains distinct data.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer n denoting the number of edges of the tree. The next line contains the edges of the binary tree.

Output:
Print the maximum path sum in the binary tree.

Constraints:
1<=T<=100
1<=n<=100
-100<=data of node<=100

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

 

**For More Examples Use Expected Output**


Contributor: Ayush Govil


					   
Result:
It is recommended to test your code before clicking 'Submit' button!



                   



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.