Getting runtime error in bfs

following is the code of bfs level order traversal.getting runtime error.pls help to resolve it.
code:

Hello @aman17nov1999 i think you have shared the wrong code:
please reshare the codeby saving it on ide.codinglbocks.com .

srry sir…right code: https://ide.codingblocks.com/s/396747

@aman17nov1999 you have to just print accorsding to the level order then try this:


if you have any further doubt you can ask here:
Happy Learning!!

sir, actually its a question from leetcode…they want ans in specific order,i.e. vector<vector>, so i have done that, but why there is runtime error i could not figure out.

please share the link of the question as well.
i will try that code and then i will share the final code with you.

sir, only tell me whats wrong in my code… q link: https://leetcode.com/problems/binary-tree-level-order-traversal/

Hello @aman17nov1999 i have corrected your code:


if you have anuy doubt you can ask here:
HappyLearning!!

no sir, this modified code is also showing runtime error.

Hello @aman17nov1999 i think you and me are just complecating the code.
we can submit likethis as well :

sir, my one solution is accepted… I only want to know where i m doing wrong in code send to you…

i think the if condition which you were handling was wrong somewherer there:
you can mark this doubt as resolved.
Happy Learning!!