Re: [LeetCode] 刷到面試 Grind169 C++

作者: SuiseiLeda (星街雷達)   2023-03-15 16:23:56
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;
}
};
作者: FuGuRo (ThisFuckingGuyRolling)   2023-03-15 16:29:00
好強喔我才剛在學資料型態==
作者: SuiseiLeda (星街雷達)   2023-03-15 16:30:00
別學了 直接開刷 不會再回頭看
作者: FuGuRo (ThisFuckingGuyRolling)   2023-03-15 16:31:00
好 跟著大師走

Links booklink

Contact Us: admin [ a t ] ucptt.com