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/construct_bt_io_po.cpp | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 other/construct_bt_io_po.cpp (limited to 'other/construct_bt_io_po.cpp') diff --git a/other/construct_bt_io_po.cpp b/other/construct_bt_io_po.cpp deleted file mode 100644 index 6fb9163..0000000 --- a/other/construct_bt_io_po.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// 106. Construct Binary Tree from Inorder and Postorder Traversal -#include "leetcode.h" - -/* - * given two integer arrays 'inorder' and 'postorder', where 'inorder' is the - * inorder traversal of a binary tree, and 'postorder' is the postorder - * traversal of the same tree, construct and return the binary tree. - */ - -class Solution { -public: - TreeNode *buildTree(vector &inorder, vector &postorder) { - int n = inorder.size(), po_idx = n - 1; - for (int i = 0; i < n; i++) - um[inorder[i]] = i; - return construct(inorder, postorder, 0, n - 1, po_idx); - } - -private: - unordered_map um; - TreeNode *construct(vector &inorder, vector &postorder, - int io_start, int io_end, int po_idx) { - if (io_start > io_end) - return nullptr; - TreeNode *root = new TreeNode(postorder[po_idx--]); - int io_idx = um[root->val]; - root->right = construct(inorder, postorder, io_idx + 1, io_end, po_idx); - root->left = construct(inorder, postorder, io_start, io_idx - 1, po_idx); - return root; - } -}; -- cgit v1.2.3