TikTok interview question

Serialize and deserialize a tree