Example 1
- Input
- root = [1,2,3,null,null,4,5]
- Output
- [1,2,3,null,null,4,5]
Node 1 has children 2 and 3; node 2 is a leaf; node 3 has children 4 and 5. Level order writes 1,2,3,N,N,4,5,N,N,N,N; preorder writes 1,2,N,N,3,4,N,N,5,N,N. Either matching decoder reconstructs the displayed tree, including both missing children of 2.