Is this the right approach?


Or should I go with printing at k level and do printing in less efficient way?

@goyalvivek there there can be multiple ways to solve a question there’s no “right” or “wrong” way, some approaches are better space optimized some are better time optimized so you have to consider all the factors according to the situation and constraints.
You can check accuracy by submitting the solution

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.

please correct my code https://ide.codingblocks.com/s/631896

Your approach is not correct
consider this case

                  20
                /    \
              8       22
            /   \      \
          5      3      25
                / \      
              10    14

Your Code output
20 8 22 3 5 25 10 14
but correcte output is
20 22 8 5 3 25 14 10

i think you got your mistake
you are are just fliping left and right data
but you have to reverse the complete level

Reference Code