diff --git a/LeetCode/606. Construct String from Binary Tree b/LeetCode/606. Construct String from Binary Tree new file mode 100644 index 0000000..a2d8460 --- /dev/null +++ b/LeetCode/606. Construct String from Binary Tree @@ -0,0 +1,26 @@ +class Solution { +public: + string str = ""; + + void dfs(TreeNode* node, TreeNode* root) { + if (node == NULL) + return; + + if (node != root) + str += '('; + str += to_string(node->val); + dfs(node->left, root); + if (node->left==NULL && node->right!=NULL) + str += "()"; + + dfs(node->right, root); + if (node != root) + str += ')'; + } + + string tree2str(TreeNode* root) { + dfs(root, root); + + return str; + } +}; diff --git a/LeetCode/609. Find Duplicate File in System b/LeetCode/609. Find Duplicate File in System new file mode 100644 index 0000000..3979d5a --- /dev/null +++ b/LeetCode/609. Find Duplicate File in System @@ -0,0 +1,40 @@ +class Solution { +public: + vector> findDuplicate(vector& paths) { + vector> ans; + unordered_map> m; + + for (auto i: paths) { + string chunk = "", path = ""; + stringstream ss(i); + + while(ss >> chunk) { + // cout<