Some LeetCode questions such as this one use a binary tree with null pointers like this:
[3,9,20,null,null,15,7]
to create a tree that looks like this:
3
/ \
9 20
/ \
15 7My own implementation of a Binary Tree (in JavaScript) works unless I try to add null as node values in an attempt to create trees with the same structure as the examples. I have searched unsuccessfully for examples of how to implement this. Can someone help me to write a Binary Tree add method which accounts for nulls in this way?