翻转二叉树
来源:互联网 发布:php split 编辑:程序博客网 时间:2024/06/11 10:30
翻转一棵二叉树
样例
1 1 / \ / \2 3 => 3 2 / \ 4 4
/** * Definition of TreeNode: * public class TreeNode { * public int val; * public TreeNode left, right; * public TreeNode(int val) { * this.val = val; * this.left = this.right = null; * } * } */public class Solution { /** * @param root: a TreeNode, the root of the binary tree * @return: nothing */ public void invertBinaryTree(TreeNode root) { if(root==null) return; TreeNode temp=root.left; root.left=root.right; root.right=temp; invertBinaryTree(root.left); invertBinaryTree(root.right); }}
阅读全文
0 0
- C++二叉树翻转
- 翻转二叉树
- 翻转二叉树
- 题目:翻转二叉树
- LintCode 翻转二叉树
- LinkCode-翻转二叉树
- 翻转二叉树
- 翻转二叉树
- 翻转二叉树
- LintCode_175_翻转二叉树
- 二叉树翻转
- lintcode ----翻转二叉树
- lintcode,翻转二叉树
- 翻转二叉树
- 翻转二叉树
- 翻转二叉树
- 翻转二叉树
- LintCode-翻转二叉树
- Android学习迷茫问下自己14个问题
- nginx源码学习2——扒、封装红黑树代码
- Redis主从复制和集群配置
- 深入浅出JMS(一)--JMS基本概念
- 用ajax向table插一条一条数据,使插入最新数据都在第一行
- 翻转二叉树
- Kotlin实战00---前言
- 在Ubuntu ROS中使用zsh
- redis在java中的使用(jedis)
- jdk1.7+Eclipse+Maven3.5+Hadoop2.7.3构建hadoop项目
- 链表—两个链表的相交问题
- qt连接oracle数据库经验总结
- dubbo分布式服务框架剖析
- Office 2016激活教程(附KMS激活软件)