diff options
Diffstat (limited to 'construct_string_binary_tree.cpp')
-rw-r--r-- | construct_string_binary_tree.cpp | 21 |
1 files changed, 0 insertions, 21 deletions
diff --git a/construct_string_binary_tree.cpp b/construct_string_binary_tree.cpp deleted file mode 100644 index a63e3c9..0000000 --- a/construct_string_binary_tree.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "leetcode.h" - -class Solution { -public: - string tree2str(TreeNode *root) { - if (!root) - return ""; - string ans = to_string(root->val); - if (root->left || root->right) { - ans.push_back('('); - ans += tree2str(root->left); - ans.push_back(')'); - } - if (root->right) { - ans.push_back('('); - ans += tree2str(root->right); - ans.push_back(')'); - } - return ans; - } -}; |