Trees Find sum at level K

im not getting how o take the input of the given tree in the format given in input

Just create an empty adjacency list and then start taking in the input. So, if the input is of the form x y, then go to node x and put the next y numbers in the adjacency list of x. Meanwhile, while storing these y inputs, you would have to store the children to each of these nodes too. So, proceed as if you are maintining a recursion stack. Lastly, input ends with a single value k.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.