Re: [閒聊] 每日leetcode

看板Marginalman作者 (xXx_5354M3_31M0_xXx)時間1年前 (2024/08/12 20:07), 編輯推噓1(101)
留言2則, 2人參與, 1年前最新討論串700/1554 (看更多)
懶得寫今天的,挑一個 binary tree 654. Maximum Binary Tree 寫一寫根本就變成練習 C++ container class Solution { public: TreeNode* constructMaximumBinaryTree(vector<int>& nums) { TreeNode* root = nullptr; constructMaximumBinaryTree(root, nums.begin(), nums.end()); return root; } private: static void constructMaximumBinaryTree(TreeNode*& root, vector<int>::iterator start, vector<int>::iterator end) { if (start == end) { return; } vector<int>::iterator maxIter = max_element(start, end); root = new TreeNode(*maxIter); constructMaximumBinaryTree(root->left, start, maxIter); constructMaximumBinaryTree(root->right, next(maxIter, 1), end); } }; -- https://i.imgur.com/07Uv9NC.png
https://i.imgur.com/YNJpGoH.png
https://i.imgur.com/G69mH5A.png
https://i.imgur.com/ptaX5iW.png
https://i.imgur.com/hEeZuph.png
https://i.imgur.com/mGTKAFz.png
https://i.imgur.com/gdejDOy.png
https://i.imgur.com/JX7AHZc.png
https://i.imgur.com/X6Pgqgi.png
https://i.imgur.com/mJ8dU86.png
-- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.228.71.204 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1723464456.A.4D2.html

08/12 20:07, 1年前 , 1F
大師
08/12 20:07, 1F

08/13 15:25, 1年前 , 2F
大師
08/13 15:25, 2F
文章代碼(AID): #1ckVi8JI (Marginalman)
討論串 (同標題文章)
文章代碼(AID): #1ckVi8JI (Marginalman)