Trees -- Find sum at level K

Question link : https://hack.codingblocks.com/contests/c/587/141
Can someone explain how to take input in this question.

Given tree input
1 2
2 2
3 0
4 0
5 2
6 0
7 0
.
.
.
.
1 2 means 1 has two child.
2 2 means 1 has first child 2 and 2 has 2 child
3 0 means 2 has first child 3 and 3 has 0 child
4 0 means 2 has second child 4 and 4 has 0 child
5 2 means 1 has second child 5 and 5 has 2 child
6 0 means 5 has first child 6 and 6 has 0 child
7 0 means 5 has second child 7 and 7 has 0 child

Tree at level 0 : 1
Tree at level 1 : 2 5
Tree at level 2 : 3 4 6 7

1 Like

I dont know whether I have ideal approach or not .
Let me tell u my approach.
My approach could be wrong bt I hope it will help you getting to some point

3 Likes

NIcely explained. Thanks a lot!

Toh like karde bhai :stuck_out_tongue:

3 Likes