Binary Tree Zigzag Level Order Traversal

Input: root = [3,9,20,null,null,15,7]
Output: [[3],[20,9],[15,7]]
  • Time Complexity: O(N), where N is the number of nodes in the tree.
  • Space Complexity: O(H), where H is the height of the tree, i.e. the number of levels in the tree, which would be roughly log2​N.

--

--

--

Full Stack Programmer, love to solve problem’s during free time.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

This is a full guide how to Run a Node and setup a “Klever” validator

Practical Guide to Migrate from JUnit 4 to JUnit5 — Part 1

Different Career Opportunities in SAP HANA

The Challenge We Took upon Our-self(Quick Report)Cross Platform APP

“Dynamic” Shared Element Transition: How to hold a common gallery flow

Interpreting the Technical Communication: Fresh Prospects

A quick note about Equality in Kotlin & Java . DIfference between == ,=== & equals()

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jaydeep

Jaydeep

Full Stack Programmer, love to solve problem’s during free time.

More from Medium

Leetcode -Coin Change

Count Binary Substrings

Leetcode Q132. Palindrome Partitioning II

The Essence of Algorithm: Prefix Sum