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

Nikhil Lohia โ€ข March 6, 2023
Video Thumbnail
Nikhil Lohia Logo

Nikhil Lohia

View Channel

About

I want to share with you my knowledge, that I have gained all my life. I like to see every task in your day to day life as an interesting problem to solve, and if you can understand the requirements, solving for it can become somewhat intuitive. I try to explore certain aspects of day to day life and how I can make them easier for you. This involves daily hacks, tutorials, innovations, new discoveries, experiences and all the stuff I find amusing. As a software engineer myself, I also believe that good problem solving skills can help you overcome most of the barriers in life. Programming is one of them. If you know how to approach a problem, writing a code for it in any language could be a very typical task. With this channel I aim to focus on the way to solve a problem efficiently rather than just its implementation.

Video Description

Actual Problem: https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ Chapters: 00:00 - Intro 00:47 - Problem Statement and Description 03:35 - Using level order traversal for zig-zag 08:54 - Dry-run of Code 13:38 - Final Thoughts ๐Ÿ“š Links to topics I talk about in the video: Level Order Traversal: https://youtu.be/9M3oCwPGamE Stack Data Structure: https://youtu.be/vrVOYj_tF7M Tree Data Structure: https://youtu.be/6jwUjPs27Pc ๐Ÿ“˜ A text based explanation is available at: https://studyalgorithms.com Code on Github: https://github.com/nikoo28/java-solutions/blob/master/src/main/java/leetcode/medium/BinaryTreeZigzagLevelOrderTraversal.java Test-cases on Github: https://github.com/nikoo28/java-solutions/blob/master/src/test/java/leetcode/medium/BinaryTreeZigzagLevelOrderTraversalTest.java ๐Ÿ“– Reference Books: Starting Learn to Code: https://amzn.to/36pU0JO Favorite book to understand algorithms: https://amzn.to/39w3YLS Favorite book for data structures: https://amzn.to/3oAVBTk Get started for interview preparation: https://amzn.to/39ysbkJ ๐Ÿ”— To see more videos like this, you can show your support on: https://www.buymeacoffee.com/studyalgorithms ๐ŸŽฅ My Recording Gear: Recording Light: https://amzn.to/3pAqh8O Microphone: https://amzn.to/2MCX7qU Recording Camera: https://amzn.to/3alg9Ky Tablet to sketch and draw: https://amzn.to/3pM6Bi4 Surface Pen: https://amzn.to/3pv6tTs Laptop to edit videos: https://amzn.to/2LYpMqn ๐Ÿ’ป Get Social ๐Ÿ’ป Follow on Facebook at: https://www.facebook.com/studyalgos Follow on Twitter at: https://www.twitter.com/studyalgorithms Follow on Tumblr at: https://studyalgos.tumblr.com/ Subscribe to RSS feeds: https://studyalgorithms.com/feed/ Join fan mail: http://eepurl.com/g9Dadv #leetcode #programming #interview

You May Also Like

Up Your Gaming Game

AI-recommended products based on this video

Loading...
acer Aspire 3 A315-24P-R7VH, 15.6" FHD 1920x1080 Laptop, AMD Ryzen 3 7320U, Radeon Graphics, 8GB RAM, 128G SSD, Windows 11 in S Mode
Best Seller

acer Aspire 3 A315-24P-R7VH, 15.6" FHD 1920x1080 Laptop, AMD Ryzen 3 7320U, Radeon Graphics, 8GB RAM, 128G SSD, Windows 11 in S Mode

(3,603)
$529.99$489.99
FREE delivery Tue, Jun 17
500+ bought in past month
Loading...
Corsair Vengeance LPX 32GB (2 X 16GB) DDR4 3200 (PC4-25600) C16 1.35V Desktop Memory - Black
Best Seller

Corsair Vengeance LPX 32GB (2 X 16GB) DDR4 3200 (PC4-25600) C16 1.35V Desktop Memory - Black

(16,675)
$112.99$101.69
FREE delivery Sun, Aug 10
500+ bought in past month
Loading...
Reatan S8 Mini PC Gaming with Intel Core i9 12900H(14C/20T 5.0 GHz), 32GB DDR5 Dual Channel 1TB NVMe SSD, Mini Desktop Computer Triple Display Support 8K WiFi6 BT5.2 USB-C

Reatan S8 Mini PC Gaming with Intel Core i9 12900H(14C/20T 5.0 GHz), 32GB DDR5 Dual Channel 1TB NVMe SSD, Mini Desktop Computer Triple Display Support 8K WiFi6 BT5.2 USB-C

(8)
$865.00
FREE delivery Mon, Aug 11
Loading...
Fanless Mini PC 13th Gen Core i7 1355U(10C/12T), Win11 Pro Mini Desktop PC Dual 2.5G LAN Mini PC Fanless, Iris Xe Graphics, Dual HD+ DP Triple Display, USB-C, WiFi6, BT5.2, 64GB RAM 1TB NVME SSD

Fanless Mini PC 13th Gen Core i7 1355U(10C/12T), Win11 Pro Mini Desktop PC Dual 2.5G LAN Mini PC Fanless, Iris Xe Graphics, Dual HD+ DP Triple Display, USB-C, WiFi6, BT5.2, 64GB RAM 1TB NVME SSD

(12)
$1,212.00
FREE delivery Aug 21 - Sep 4
Loading...
Beelink SER5 MAX Mini PC, AMD Ryzen 7 6800U(8C/16T, Up to 4.7GHz), Mini Computer 32G LPDDR5 RAM 1TB NVMe PCIE4.0 SSD, Mini Desktop Computer 4K@144Hz Triple Display HDMI2.1/DP/WiFi6/BT5.2/W-11 Pro

Beelink SER5 MAX Mini PC, AMD Ryzen 7 6800U(8C/16T, Up to 4.7GHz), Mini Computer 32G LPDDR5 RAM 1TB NVMe PCIE4.0 SSD, Mini Desktop Computer 4K@144Hz Triple Display HDMI2.1/DP/WiFi6/BT5.2/W-11 Pro

(656)
$569.00
FREE delivery Sun, Aug 10
Loading...
Skytech Chronos 3 Gaming PC Desktop, Ryzen 7 9700X 3.8 GHz (5.5GHz Turbo), NVIDIA RTX 5060 8GB, 1TB NVMe SSD, 32GB DDR5 RAM 5200 RGB, 850W Gold ATX 3 PSU, 360mm ARGB AIO, Wi-Fi, Win 11

Skytech Chronos 3 Gaming PC Desktop, Ryzen 7 9700X 3.8 GHz (5.5GHz Turbo), NVIDIA RTX 5060 8GB, 1TB NVMe SSD, 32GB DDR5 RAM 5200 RGB, 850W Gold ATX 3 PSU, 360mm ARGB AIO, Wi-Fi, Win 11

(50)
$1,995.40
FREE delivery Jul 6 - 30
Loading...
Logitech G203 Wired Gaming Mouse, 8,000 DPI, Rainbow Optical Effect LIGHTSYNC RGB, 6 Programmable Buttons, On-Board Memory, Screen Mapping, PC/Mac Computer and Laptop Compatible - Black
Best Seller

Logitech G203 Wired Gaming Mouse, 8,000 DPI, Rainbow Optical Effect LIGHTSYNC RGB, 6 Programmable Buttons, On-Board Memory, Screen Mapping, PC/Mac Computer and Laptop Compatible - Black

(17,871)
$27.98$22.38
FREE delivery Tue, Oct 14 on your first order
500+ bought in past month
Loading...
CORSAIR iCUE Link XD5 RGB Elite LCD Pump-Reservoir Unit - D5 PWM Pump - 480x480 IPS LCD Screen - 22 Addressable RGB LEDs - 440ml Nylon Reservoir - White

CORSAIR iCUE Link XD5 RGB Elite LCD Pump-Reservoir Unit - D5 PWM Pump - 480x480 IPS LCD Screen - 22 Addressable RGB LEDs - 440ml Nylon Reservoir - White

(17)
$379.99
FREE delivery Sun, Aug 24
Loading...
CORSAIR iCUE Link XC7 RGB Elite CPU Water Block - Transparent Flow Chamber - 24 RGB LEDs - Fits Intelยฎ LGA 1700, AMDยฎ AM5 and Older - White

CORSAIR iCUE Link XC7 RGB Elite CPU Water Block - Transparent Flow Chamber - 24 RGB LEDs - Fits Intelยฎ LGA 1700, AMDยฎ AM5 and Older - White

(56)
$149.99$125.33
FREE delivery Sun, Aug 24
Loading...
CORSAIR Hydro X Series iCUE Link XH405i Custom Cooling Kit โ€“ Hardline Water Cooling Loop โ€“ XC7 Elite CPU Water Block โ€“ XD5 Elite D5 Pump Res โ€“ XR5 360mm Radiator โ€“ 3X QX120 RGB Fans

CORSAIR Hydro X Series iCUE Link XH405i Custom Cooling Kit โ€“ Hardline Water Cooling Loop โ€“ XC7 Elite CPU Water Block โ€“ XD5 Elite D5 Pump Res โ€“ XR5 360mm Radiator โ€“ 3X QX120 RGB Fans

(235)
$879.99
FREE delivery Sun, Aug 24
Loading...
Razer BlackShark V2 X Gaming Headset: 50mm Drivers - Cardioid Mic - Memory Foam Cushion - Lightweight- Comfortable, Noise Isolating Earcups - for PC, PS4, PS5, Switch - 3.5mm Audio Jack - Black ECOLOGO

Razer BlackShark V2 X Gaming Headset: 50mm Drivers - Cardioid Mic - Memory Foam Cushion - Lightweight- Comfortable, Noise Isolating Earcups - for PC, PS4, PS5, Switch - 3.5mm Audio Jack - Black ECOLOGO

(16,830)
$47.98$38.38
FREE delivery Sat, Nov 15
1K+ bought in past month
Loading...
Razer Universal Quick Charging Stand for Xbox Series X|S: Magnetic Secure Charging - Matches Forza Horizon 5 Limited Edition Xbox Wireless Controller - USB Powered - (Controller Sold Separately)

Razer Universal Quick Charging Stand for Xbox Series X|S: Magnetic Secure Charging - Matches Forza Horizon 5 Limited Edition Xbox Wireless Controller - USB Powered - (Controller Sold Separately)

(1,103)
$52.27$33.70
PrimeFREE delivery Sat, Jun 14