Question

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).

This is atree question.

Idea(s)

  • “Level” indicates using a BFS solution
  • Essentially just a regular BFS except we keep track of layers using None objects, we append node values to a level list and whenever we see a None, we append the level list to res
  • Pretty easy

Solution