LeetCode 297 Serialize and Deserialize Binary Tree - Problem Statement

The problem

Design an algorithm to serialize a binary tree to a string and deserialize that string back to the original tree.

With this tree:

   1
  / \
 2   3
    / \
   4   5

A valid serialization might be "1,2,null,null,3,4,null,null,5,null,null" (preorder with nulls).

serialize(root) returns a string encoding the tree. deserialize(data) returns the original tree.

The format is up to you, as long as both methods work together.

Constraints: Up to 10410^4 nodes. Values from 1000-1000 to 10001000.