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

The underbelly of the software development lifecycle

Evernote Home or Shortcuts?

CRUD Operation Using RealmSwift Part 1

Using Python to automate your boring and tedious excel tasks!

MEAN Stack Vs MERN Stack: Which One Is Better?

Languages you need to learn to apply at a Job Interview!

Staffing: Externals, students, etc.

Functional Programming With Java: Map, Filter, and Reduce

chopping board with vegetables, eggs, herbs and knife

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

Maximum Points You Can Obtain from Cards — LeetCode

Leetcode Q521. Longest Uncommon Subsequence I (Q440)

Leetcode — 55. Jump Game (Medium)

[Leetcode] Backspace String Compare