Home > Enterprise >  Confused about the way Leetcode displays binary trees?
Confused about the way Leetcode displays binary trees?

Time:02-07

I'm currently practicing binary tree exercises on Leetcode and am often confused. I'm currently solving this enter image description here

CodePudding user response:

When you do a level-ordered traversal of the tree, the array elements go in each open slot you encounter, so:

           1
          / \
       null  2
            / \
         null  3

CodePudding user response:

The test case represents invalid input. In other words, you're right that it makes no sense. Leetcode wants to know how your program handles it.

  •  Tags:  
  • Related