Sir I think in 3rd approach(2 stack) , the first while condition should have && operator instead of || operator. Because at end both the stack becomes empty , so 1st while condition remain always true due to s2.empty() gives always true. It gives TLE.
Right. Thanks for pointing out. ! was missing in the while statement. Fixed it. github.com/fit-coder/fitcoderyoutube/blob/master/tree/zigzag_level_order_traversal_two_stacks.cpp
Idea is most important. Coz idea can be applied to different questions. That being said it's good to know solutions for the frequently asked questions.
00:00 Introduction
00:06 Zigzag traversal
01:15 1.Zigzag traversal using recursion
03:14 2.Zigzag traversal using stack and queue
11:11 3.Zigzag traversal using 2 stacks
16:14 4.Zigzag traversal using deque
22:50 C++ Implementation
Only video that has all the methods explained in a concise manner....hats off.
thank you :)
thanks for explaining all the methods....most videos just explain one of the methods....you took time to explain all. cheers.
You're welcome!
Thanks for making such detailed video. Really helpful!
Glad you enjoyed it!
I like the two stack approach....that was interesting. Thanks for sharing.
Glad you enjoyed it
Sir I think in 3rd approach(2 stack) , the first while condition should have && operator instead of || operator. Because at end both the stack becomes empty , so 1st while condition remain always true due to s2.empty() gives always true. It gives TLE.
Right. Thanks for pointing out. ! was missing in the while statement. Fixed it.
github.com/fit-coder/fitcoderyoutube/blob/master/tree/zigzag_level_order_traversal_two_stacks.cpp
Hello sir
For all of these algorithms, we must memories all of them or the most important thing is to understand the trick or the idea ?
Idea is most important. Coz idea can be applied to different questions. That being said it's good to know solutions for the frequently asked questions.
@@FitCoder
For the interviews, you must write all the entire algorithm or you can tell the examiner only by the idea how we solve that problem ?
Entire algorithm is required.
sir can you make a whatsapp or insta group where everyone can ask doubts?
For now, you can write doubts in the comment section. I will reply there surely.