Company: Mastercard_2ndaug
Difficulty: medium
Problem Description A binary tree is represented as a series of relationships between each node and the Root node. The relationships are denoted as combinations of 'L' and 'R', such as L, R, LL, LR, and so on, where each node is left (L) to Root or left (LL) or right left (RL) to the Root node and so on. In this tree, if the sum of digits of the left child node is equal to the sum of digits of the right child node, then their parent is called a Super Node. Write a program to find all the Super Nodes in a given tree, and print the sum of all those Super Nodes. Read the input from STDIN and print the output to STDOUT. Do not write arbitrary strings in the program, as these contribute to the standard output and testcases will fail. Constraints 3 <= N <= 100 Input Format The first line of input contains integer N, the number of nodes in the tree. The second line of input contains the Root node. The next N-1 lines of input contain a string S, and an integer X, separated by a single wh