Zig Zag Traversal (LeetCode 103) | Full Solution with visuals and a little trick | Study Algorithms

  Рет қаралды 9,982

Nikhil Lohia

Nikhil Lohia

Күн бұрын

Пікірлер: 31
@floatingfortress721
@floatingfortress721 10 ай бұрын
Thanks! After watching this video I was able to solve a similar leetcode question, "Binary Tree Right Side View"
@nikoo28
@nikoo28 9 ай бұрын
that is wonderful
@himanshisingh9
@himanshisingh9 Жыл бұрын
loved the approach. writing how we made queue for level order and then thinking about how we can achieve zig zag pattern with small tweaks. thanks😇
@nikoo28
@nikoo28 11 ай бұрын
Glad you liked it.
@meenakshiwadhwa4625
@meenakshiwadhwa4625 26 күн бұрын
Loved the explanation. I like the way you teach. Thanks for great content !!
@akshayrajsingh555
@akshayrajsingh555 Жыл бұрын
Congratulations for 10k 🥳
@susmitapatil4847
@susmitapatil4847 7 ай бұрын
Best Explanation. Keep doing good work.
@saurabhruikar1131
@saurabhruikar1131 10 ай бұрын
As always very nice explanation, I would like to suggest a tweak instead of using stack we could simply reverse temporayList at alternate iteration.
@nikoo28
@nikoo28 9 ай бұрын
That's a great idea!
@xxxlr1
@xxxlr1 15 күн бұрын
You are awesome and I love your video explanations! My solution was similar but instead of using a stack, I reversed the created list for each level and added it to the final answer list based on the boolean flag. Is it the same as your solution as far as Time and Space complexity, or is it worse?
@nikoo28
@nikoo28 11 күн бұрын
as long as the time and space complexity is same, doesn't really matter
@ghanashrim2839
@ghanashrim2839 Жыл бұрын
The way you approach a new problem is something I'd really like to learn. Amazing explanation as usual. What software do you use for video recording and editing? Is this iPad mirrored on the screen and then screen recorded?
@nikoo28
@nikoo28 Жыл бұрын
I use final cut pro for all the edits, and on iPad I use GoodNotes 5
@ghanashrim2839
@ghanashrim2839 Жыл бұрын
@@nikoo28 Thank you :)
@tanishkaagarwal6750
@tanishkaagarwal6750 8 ай бұрын
Thank you for the wonderful explanation sir
@LalitSingh-nd5vx
@LalitSingh-nd5vx 10 ай бұрын
thanks for awesome explanation !
@amitbhattacharya356
@amitbhattacharya356 Жыл бұрын
There is a small mistake in the code while adding popped element from stack to level, which is self explanatory: Fixed code: TreeNode node = reverseStack.pop(); level.add(node.val); Appreciate your effort, thanks.
@nikoo28
@nikoo28 Жыл бұрын
Thanks for clearing it out. :)
@saifahmad141
@saifahmad141 Жыл бұрын
which line??even the one on screen is running correct
@deepondas5001
@deepondas5001 8 ай бұрын
sir i would say you have great approach and explanation skill if you have done a great marketing then you may have thousands of views
@avinashtiwari4025
@avinashtiwari4025 9 ай бұрын
can you also explain how we compute the space complexity for this ?
@nikoo28
@nikoo28 8 ай бұрын
space complexity is simply the extra space we use to arrive at our solution. We use a stack, that can have the maximum of n elements in the worst case. Hence, space complexity is O(n)
@manishasharma-mh7fo
@manishasharma-mh7fo Жыл бұрын
sir could u pls make a video on boundary order traversal .
@nikoo28
@nikoo28 Жыл бұрын
can you give me an example link?
@mjeevan2408
@mjeevan2408 Жыл бұрын
hi sir. I seen Ur backtracking video , I commented below that video can u replay for that comment.
@nikoo28
@nikoo28 Жыл бұрын
How can I help you?
@navyashreeamam753
@navyashreeamam753 Жыл бұрын
@@nikoo28 I want more default problems with solutions on backtracking algorithm can u Make problems on that ,sir
@SibiRanganathL
@SibiRanganathL Ай бұрын
Understood
@vibhanshusharma9143
@vibhanshusharma9143 10 ай бұрын
Bro for instead of stack we can simply reverse a vector Batao m puch rha hu😅
@pragyaprashar7165
@pragyaprashar7165 Жыл бұрын
Hey Nikhil, I have messaged you on LinkedIn.
How to use LeetCode and pick problems to solve effectively in #2024
14:54
Creative Justice at the Checkout: Bananas and Eggs Showdown #shorts
00:18
Fabiosa Best Lifehacks
Рет қаралды 8 МЛН
Twin Telepathy Challenge!
00:23
Stokes Twins
Рет қаралды 119 МЛН
FOREVER BUNNY
00:14
Natan por Aí
Рет қаралды 31 МЛН
Мама у нас строгая
00:20
VAVAN
Рет қаралды 11 МЛН
DSA Phir se with Sumeet | Leetcode 6 | Zigzag Conversion
17:54
L19. Zig-Zag or Spiral Traversal in Binary Tree | C++ | Java
8:21
take U forward
Рет қаралды 262 М.
Creative Justice at the Checkout: Bananas and Eggs Showdown #shorts
00:18
Fabiosa Best Lifehacks
Рет қаралды 8 МЛН