Tree find sum at level K

https://hack.codingblocks.com/practice/p/355/141

can u tell how the children of a nodes are decided through input(what interpretation this input makes)

Hey Harshita, in this problem we are taking input for a generic tree, at each step you are getting the node’s data and how many children it would have. For eg.
input:
1 2
2 2
3 0
4 0
5 2
6 0
7 0
2

Here 1 2 denotes 1 is root node data and it will be having 2 child then
2 2 denotes 1 is root node data and it will be having 2 child then
3 0 denotes 1 is root node data and it will be having 0 child,
similarly it goes on and at last 2 denotes the level at which you have to calculate the sum of nodes.

Level order of this tree:
level 0: 1
level 1: 2 5
level 2: 3 4 6 7