精華區beta Marginalman 關於我們 聯絡資訊
226. Invert Binary Tree easy題 二差樹歷遍而已 難得我會 但我runtime跟memory超爛 是要改迭代比較好嗎 class Solution { public: TreeNode* invertTree(TreeNode* root) { if(root == NULL) return root; invertTree(root->left); invertTree(root->right); swap(root->left, root->right); return root; } }; -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.113.136.220 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1678868638.A.19C.html
FuGuRo: 好強喔我才剛在學資料型態== 03/15 16:29
SuiseiLeda: 別學了 直接開刷 不會再回頭看 03/15 16:30
FuGuRo: 好 跟著大師走 03/15 16:31