in the first approach discussed, in which pairs are inserted in the queue, how will get to know the level number ???
How will i get to n=know that i have entered a new level?
hey @sirraghavgupta, you need to maintain the a variable (let say count). This variable count is initialised with value 0, Now when you push first entry, it will (root,count) . Whenever you pop the a entry from queue, you need to increase the value of count by 1.
Hence count will represent level no.
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.