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

  Рет қаралды 10,460

Nikhil Lohia

Nikhil Lohia

Күн бұрын

Пікірлер: 35
@meenakshiwadhwa4625
@meenakshiwadhwa4625 2 ай бұрын
Loved the explanation. I like the way you teach. Thanks for great content !!
@akshayraj_singh
@akshayraj_singh Жыл бұрын
Congratulations for 10k 🥳
@floatingfortress721
@floatingfortress721 11 ай бұрын
Thanks! After watching this video I was able to solve a similar leetcode question, "Binary Tree Right Side View"
@nikoo28
@nikoo28 10 ай бұрын
that is wonderful
@susmitapatil4847
@susmitapatil4847 8 ай бұрын
Best Explanation. Keep doing good work.
@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 Жыл бұрын
Glad you liked it.
@LalitSingh-nd5vx
@LalitSingh-nd5vx 11 ай бұрын
thanks for awesome explanation !
@Mydailymutualfundportfolio
@Mydailymutualfundportfolio 25 күн бұрын
Very good explanation 🎉❤
@nikoo28
@nikoo28 24 күн бұрын
Thanks for the love!
@tanishkaagarwal6750
@tanishkaagarwal6750 10 ай бұрын
Thank you for the wonderful explanation sir
@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 :)
@deepondas5001
@deepondas5001 9 ай бұрын
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
@saurabhruikar1131
@saurabhruikar1131 11 ай бұрын
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 10 ай бұрын
That's a great idea!
@xxxlr1
@xxxlr1 Ай бұрын
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 Ай бұрын
as long as the time and space complexity is same, doesn't really matter
@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
@SibiRanganathL
@SibiRanganathL 2 ай бұрын
Understood
@avinashtiwari4025
@avinashtiwari4025 10 ай бұрын
can you also explain how we compute the space complexity for this ?
@nikoo28
@nikoo28 9 ай бұрын
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)
@ssss22144
@ssss22144 17 күн бұрын
please start graph problems also anna
@nikoo28
@nikoo28 17 күн бұрын
Did you have a look at my playlist on graphs?
@manishasharma-mh7fo
@manishasharma-mh7fo Жыл бұрын
sir could u pls make a video on boundary order traversal .
@nikoo28
@nikoo28 Жыл бұрын
can you give me an example link?
@vibhanshusharma9143
@vibhanshusharma9143 11 ай бұрын
Bro for instead of stack we can simply reverse a vector Batao m puch rha hu😅
@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
@pragyaprashar7165
@pragyaprashar7165 Жыл бұрын
Hey Nikhil, I have messaged you on LinkedIn.
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
L19. Zig-Zag or Spiral Traversal in Binary Tree | C++ | Java
8:21
take U forward
Рет қаралды 270 М.
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 904 М.
8 Data Structures Every Programmer Should Know
17:09
ForrestKnight
Рет қаралды 224 М.
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 746 М.