Company: hirepro_sde_intern_offcampus

Difficulty: medium

Problem Statement

A binary tree made of N nodes is given. A node in this tree is called a 'Balanced Node', if the sum of one subtree (either left/right) of the node is even, and the sum of the other subtree is odd. Clearly, the nodes having only one or no child nodes can never be Balanced Nodes. The tree is represented as a series of relationships of each node to the Root node such as L, R, LL, LR... and so on, where each node is left (L) to Root or left-left (LL) or right-left (RL) to Root and so on. Write a program to find all the Balanced Nodes in the tree, and print their sum as the output. Read the input from STDIN and print the output to STDOUT. Do not print arbitrary strings anywhere in the program, as these contribute to the output and testcases will fail. Constraint: 3 <= N <= 100 Input Format: The first line of input contains 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

More hirepro_sde_intern_offcampus OA questionsInterview experiences