lintcode翻转二叉树
来源:互联网 发布:淘宝上的pa改异形 编辑:程序博客网 时间:2024/05/20 01:09
翻转二叉树
Accepted
总耗时: 254 ms
100% 数据通过测试.
还没解决的相关题目
太牛了,把AC的喜悦分享给你的朋友吧!
解析:这道题的树并不是二叉查找树,所以对每个结点的左右结点交换即可。
/** * Definition of TreeNode: * class TreeNode { * public: * int val; * TreeNode *left, *right; * TreeNode(int val) { * this->val = val; * this->left = this->right = NULL; * } * } */class Solution {public: /* * @param root: a TreeNode, the root of the binary tree * @return: nothing */ void invertBinaryTree(TreeNode * root) { // write your code here if(root==NULL) return ; invertBinaryTree(root->left);//后续遍历,先对左右结点操作 invertBinaryTree(root->right); TreeNode *tmp; tmp=root->left; root->left=root->right; root->right=tmp; }};
阅读全文
0 0
- LintCode 翻转二叉树
- lintcode ----翻转二叉树
- lintcode,翻转二叉树
- LintCode-翻转二叉树
- LintCode 翻转二叉树
- 翻转二叉树-LintCode
- lintcode 翻转二叉树
- LintCode 翻转二叉树
- 翻转二叉树-LintCode
- lintcode翻转二叉树
- LintCode - 175.翻转二叉树
- lintcode 175 翻转二叉树
- [LintCode]175.翻转二叉树
- [Lintcode] #175 翻转二叉树
- 二叉树专题-lintcode翻转二叉树
- LintCode --invert-binary-tree(翻转二叉树)
- LintCode--翻转二叉树(非递归)
- lintcode——翻转二叉树
- dd磁盘io测试
- sublime python配置
- Transmit 最好用的 FTP 传输软件 for Mac
- 实现把一个无符号数的二进制位模式从左到右反转后输出。例如:在32位机器下,把25,0~011001变成100110~0
- Codeforces 816B (前缀和算法)
- lintcode翻转二叉树
- 学习python的成长之路
- php 模糊查询数据库的技巧,以及数据分页原理, Date转换
- 11/2
- JavaFX ListView使用和样式设置
- Fresco 初体验各种问题解决
- Ubuntu 14.04 server 64bit安装jdk
- JAVA基础复习五-数组及栈堆内存分配
- 70. Climbing Stairs