From a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 Mon Sep 17 00:00:00 2001 From: Jack Sangdahl Date: Fri, 27 Jun 2025 12:23:02 -0600 Subject: chore: remove old cpp and rust solutions --- other/find_duplicate_subtree.cpp | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 other/find_duplicate_subtree.cpp (limited to 'other/find_duplicate_subtree.cpp') diff --git a/other/find_duplicate_subtree.cpp b/other/find_duplicate_subtree.cpp deleted file mode 100644 index 5880fc8..0000000 --- a/other/find_duplicate_subtree.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// 652. Find Duplicate Subtrees -#include "leetcode.h" - -/* - * given 'root' of a binary tree, return all duplicate subtrees. for each kind - * of duplicate, only return the root node of any one of them. two trees are - * duplicate if they have the same structure with the same node values. - */ - -class Solution { -public: - vector findDuplicateSubtrees(TreeNode *root) { - unordered_map> map; - vector dups; - serialise(root, map); - for (auto it = map.begin(); it != map.end(); it++) - if (it->second.size() > 1) - dups.push_back(it->second[0]); - return dups; - } - -private: - string serialise(TreeNode *node, - unordered_map> &map) { - string s = "(" + serialise(node->left, map) + to_string(node->val) + - serialise(node->right, map) + ")"; - map[s].push_back(node); - return s; - } -}; -- cgit v1.2.3