Confused about the way Leetcode displays binary trees?

Viewed 68

I'm currently practicing binary tree exercises on Leetcode and am often confused. I'm currently solving this excercise. And one of the test cases is displayed as [1, null,2, null,3]. I can not figure out what kind of binary tree this should be. When printing the tree does Leetcode simply omit some null nodes? Does the node with the value 3 belong to the node with the value 2?

enter image description here

1 Answers

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
Related