Serialize and Deserialize Binary Tree
Design an algorithm to serialize and deserialize a binary tree. There is no restriction on how your serialization/deserialization algorithm should work.

30:00

Serialize and Deserialize Binary Tree
hard
Topics
Companies

Design an algorithm to serialize and deserialize a binary tree. There is no restriction on how your serialization/deserialization algorithm should work.

Example 1:
Input: {"root":[1,2,3,null,null,4,5]}
Output: [1,2,3,null,null,4,5]
Constraints:
  • The number of nodes is in the range [0,104][0, 10^4].

  • 1000Node.val1000-1000 \leq \text{Node.val} \leq 1000

Input
arr ={"root":[1,2,3,null,null,4,5]}

Created root 1

1

Variables
No variables to display
DepthFunction Call
Stack empty
0/11