// Encodes a tree to a single string. string serialize(TreeNode* root) { string s; se_helper(root, s); // cout <<s << endl; return s; }
// Decodes your encoded data to tree. TreeNode* deserialize(string data) { if(data == "x#") return nullptr; auto iter = data.begin(); return deserialize1(iter, data.end()); }