To solve this problem, you'll have to open it on the computer

Binary Tree Level Order Traversal

Tree
easy
Score: 40

Given the root of a binary tree, return the level order traversal of its nodes’ values. (i.e., from left to right, level by level).

Class TreeNode:
    val (int)
    left (TreeNode)
    right (TreeNode)

Input Format

First Parameter - TreeNode root

Output Format

Return the 2d array of integer nodes in levelorder sequence

Example 1

Input: 
    1 null 2 null 5 3 6 null 4
Output: 
    [[1],[2],[5],[3,6],[4]]

Example 2

Input:
    15 10 12 13 null 5 null null 4
Output:  
    [[15],[10,12],[13,5],[4]]

Constraints:

  • The number of nodes in the tree is in the range [0, 2000]
  • -1000 <= Node.val <= 1000
  • Expected Time Complexity: O(n)
  • Expected Space Complexity: O(n)
Submit code to see the your result here