LeetCode 226. Invert Binary Tree
来源:互联网 发布:mac传照片到iphone 编辑:程序博客网 时间:2024/06/03 20:56
226. Invert Binary Tree
Description
Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1
Solution
- 题目意思就是将一棵二叉树每个节点的儿女倒换
- 思路很简单,先把当前结点的儿女倒换,然后递归处理儿女,代码如下
class Solution {public: TreeNode* invertTree(TreeNode* root) { if (!root) return NULL; swap(root->left,root->right); invertTree(root->left); invertTree(root->right); return root; }};
阅读全文
0 0
- LeetCode 226. Invert Binary Tree
- [leetcode] 226.Invert Binary Tree
- [leetcode] 226. Invert Binary Tree
- 【LeetCode】226. Invert Binary Tree
- leetCode 226. Invert Binary Tree
- LeetCode #226. Invert Binary Tree
- [LeetCode]226. Invert Binary Tree
- 226. Invert Binary Tree LeetCode
- LeetCode 226. Invert Binary Tree
- LeetCode 226. Invert Binary Tree
- leetcode:226. Invert Binary Tree
- LeetCode 226. Invert Binary Tree
- [LeetCode]226. Invert Binary Tree
- leetcode 226. Invert Binary Tree
- 【LeetCode】226. Invert Binary Tree
- #leetcode#226. Invert Binary Tree
- LeetCode *** 226. Invert Binary Tree
- leetcode: 226. Invert Binary Tree
- 高质量PHP代码
- 常用的PHP代码汇总
- PHP常用代码
- es6-Proxy
- 关于电力系统标准规约的一些理解
- LeetCode 226. Invert Binary Tree
- PHP程序中的文件锁、互斥锁、读写锁使用技巧解析
- android xml 布局错误
- python安装easygui
- 优化技巧
- 一些php技巧与注意事项分析
- 前言
- Missing styles. Is the correct theme chosen for this layout?
- PHP入门教程之日期与时间操作技巧总结(格式化,验证,获取,转换,计算等)