Please help i am not able to return the sum of nodes at level k but i made the code to print the level at a particular level k how can i convert this code so that it can give me the the desired output

Hello @anshulgurawalia if you’re able to print the nodes then what you can do is store them in sn array or vector then take sum.

only passing one test case

@anshulgurawalia check this:


you were not forming the tree in the correct way;

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.