Leetcode 226. Invert Binary Tree (Easy) (cpp)
来源:互联网 发布:中级程序员证书有用嘛 编辑:程序博客网 时间:2024/04/24 11:41
Leetcode 226. Invert Binary Tree (Easy) (cpp)
Tag: Tree
Difficulty: Easy
/*226. Invert Binary Tree (Easy)Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1*//** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: TreeNode* invertTree(TreeNode* root) { if (!root || !(root -> left) && !(root -> right)) return root; else { swap(root -> left, root -> right); invertTree(root -> left); invertTree(root -> right); } return root; } };
0 0
- Leetcode 226. Invert Binary Tree (Easy) (cpp)
- 【leetcode】【Easy】【226. Invert Binary Tree】【tree】
- LeetCode 226. Invert Binary Tree (Easy)
- 226. Invert Binary Tree (Easy)
- 226.leetcode Invert Binary Tree(easy)[二叉树 递归]
- [Leetcode 226, Easy] Invert Binary Tree
- <LeetCode><Easy>226Invert a binary tree
- LeetCode #226 - Invert Binary Tree - Easy
- 【Leetcode-easy-226】Invert Binary Tree
- leetcode 日经贴,Cpp code -Invert Binary Tree
- Invert Binary Tree(easy)
- 226. Invert Binary Tree [easy] (Python)
- Easy-题目4:226. Invert Binary Tree
- 226. Invert Binary Tree Difficult: Easy
- LeetCode 226. Invert Binary Tree
- [leetcode] 226.Invert Binary Tree
- [leetcode] 226. Invert Binary Tree
- 【LeetCode】226. Invert Binary Tree
- 大话设计模式17----适配器模式
- JSESSIONID
- JDBC连接MySQL数据库步骤
- FZU 2020 组合 [ Lucas ]
- 【安卓自定义控件系列】安卓自定义控件之组合控件
- Leetcode 226. Invert Binary Tree (Easy) (cpp)
- JSP技术(三)——JSP运行原理和九大隐式对象
- 非Windows操作系统导入ThinkPHP.php出错
- 渲染世界的Opengl<前言>
- **JQUERY** jQuery与HTML
- HDU 5477 A Sweet Journey
- 【杭电 2098】分拆素数和
- 车联网应用
- Java三大框架之struts的验证框架(验证字段)