Re: [閒聊] 每日LeetCode

看板Marginalman作者 (蘇菲・諾伊恩謬拉)時間5月前 (2023/12/09 12:09), 編輯推噓1(102)
留言3則, 3人參與, 5月前最新討論串570/719 (看更多)
連三天都是easy爛題是怎樣 = = https://leetcode.com/problems/binary-tree-inorder-traversal/ 這個我就跳過解釋直接付code class Solution { public: vector<int> inorderTraversal(TreeNode* root) { vector<int> output; stack<TreeNode*> temp; TreeNode* cur = root; while (!temp.empty() || cur) { while (cur) { temp.push(cur); cur = cur->left; } cur = temp.top(); temp.pop(); output.push_back(cur->val); cur = cur->right; } return output; } }; -- 噗尼都會的鍊金術...... 如、如果是這個的話,我說不定也能學會! -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 97.99.29.95 (美國) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1702094953.A.533.html

12/09 12:11, 5月前 , 1F
大師
12/09 12:11, 1F

12/09 12:54, 5月前 , 2F
這個月都easy 欸 好爽
12/09 12:54, 2F

12/09 13:11, 5月前 , 3F
大師
12/09 13:11, 3F
文章代碼(AID): #1bS-XfKp (Marginalman)
討論串 (同標題文章)
文章代碼(AID): #1bS-XfKp (Marginalman)