Diwali Offer!Flat 20% OFF
Enroll Now
PrakalpanaLive online tech training

111. Binary Tree Level Order Traversal

MediumDay 33 of 60Trees & BST

Given the root of a binary tree, return its node values level by level: a list whose first element holds the root's value, the second holds the values on depth 1 from left to right, and so on.

Example 1
Input: root = [3,9,20,null,null,15,7]
Output: [[3],[9,20],[15,7]]
Example 2
Input: root = []
Output: []
Constraints
  • The number of nodes is in the range 0 to 2000
  • -1000 <= Node.val <= 1000
Hints
Frequently asked at: Amazon, Microsoft, Meta, LinkedIn, Adobe
Ctrl + Enter runs the examples

Not sure what to learn next?

A 1-on-1 session with an industry mentor and a roadmap built for you. How it works

  1. 1Discuss your goals
  2. 2Get a personal plan
  3. 3Start learning
Book for β‚Ή200/ 30 min