short and clean solution
\nclass Codec {\npublic:\n\n    string serialize(TreeNode* root) {\n        if(!root)return "#";\n        return to_string(root->val)+"#"+serialize(root->left) 
```\nclass Codec {\npublic:\n\n    string serialize(TreeNode* root) {\n        if(!root)return "#";\n        return to_string(root->val)+"#"+serialize(root->left) + serialize(root->right);\n    }\n    TreeNode* decode(stringstream& take,string res = ""){\n        getline(take,res,\'#\');\n        if(res.empty())return NULL;\n        \n        TreeNode* root= new TreeNode(stoi(res));\n        root->left = decode(take), root->right = decode(take);\n        return root;\n    }\n\n    // Decodes your encoded data to tree.\n    TreeNode* deserialize(string data) {\n        stringstream take(data);\n        return decode(take);\n    }\n};\n\n```
['C']