darrenfu/LeetcodePy

Cruise

Closed this issue · 1 comments

12/10/2019

297. Serialize and Deserialize Binary Tree

Follow-up:

  1. What if we cannot use delimiter like comma or space.
  2. 428. Serialize and Deserialize N-ary Tree - interviewer just mentioned it, not test it.

I use preorder traverse.
For follow-up, I mentioned about convert the string array into a binary payload, and store the offset for each node value in the header meta. E.g.
[header: totalLength,[offset0,offset1,offset2,...]][payload: ]