ostringstream || istringstream
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Codec {\npublic:\n    // Encodes a tree to a single string.\n    string serialize(TreeNode* root) {\n        ostringstream ss;\n        Helper1(root, ss);\n        return ss.str();\n    }\n\n    void Helper1(TreeNode* root, ostringstream& ss) {\n        if (root == NULL) {\n            ss << "# ";\n            return;\n        }\n        ss << root->val << " ";\n        Helper1(root->left, ss);\n        Helper1(root->right, ss);\n    }\n\n    // Decodes your encoded data to tree.\n    int i;\n\n    TreeNode* deserialize(string data) {\n        istringstream ss(data);\n        vector<string>ans;\n        string an;\n\n        while (ss >> an) {\n            ans.push_back(an);\n        }\n\n        i = 0;\n        return Helper2(ans);\n    }\n\n    TreeNode* Helper2(vector<string>& ans) {\n        if (ans[i] == "#") {\n            i++;\n            return NULL;\n        }\n        TreeNode* root = new TreeNode(stoi(ans[i]));\n        i++;\n        root->left = Helper2(ans);\n        root->right = Helper2(ans);\n        return root;\n    }\n};\n\n```
['C++']