The input [1,null,2,3]
represents the serialized format of a binary tree using level order traversal, where null
signifies a path terminator where no node exists below.
We provided a Tree Visualizer tool to help you visualize the binary tree while you are solving problems. By opening the console panel, you should see a Tree Visualizer toggle switch under the TestCase tab. Click on it and it will show the test case's binary tree representation.
StefanPochmann also made an interesting tree visualizer tool for Python.
Examples:
[]
Empty tree.
The root is a reference toNULL
(C/C++),null
(Java/C#/Javascript),None
(Python), ornil
(Ruby).[1,2,3]
[1,null,2,3]
[5,4,7,3,null,2,null,-1,null,9]