[LeetCode] Serialize and Deserialize Binary Tree

  • 时间:
  • 浏览:2
  • 来源:大发5分排列5_极速5分排列3

I adopt a way similar to that of the OJ to serialize the binary tree. For the following tree, my serialization result is "1,2,3,null,null,4,5," (note the last comma).

The serialization and deserialization both use the BFS traversal. The code is as follows.