← All problems

Serialize and Deserialize Binary Tree

Hard treesdesigndfs LeetCode ↗
Design an algorithm to serialize a binary tree to a string and back.

Hints (0/3 revealed)

Log in to reveal hints progressively.

Complexity

Time O(n), Space O(n)

Common pitfalls

  • Ambiguous encoding without null markers
  • Shared mutable index bugs

Your solution

Log in to save your code and track progress.