博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Invert Binary Tree
阅读量:2341 次
发布时间:2019-05-10

本文共 579 字,大约阅读时间需要 1 分钟。

Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so fuck off.

/** * Definition for a binary tree node. * public class TreeNode { *     int val; *     TreeNode left; *     TreeNode right; *     TreeNode(int x) { val = x; } * } */public class Solution {
public TreeNode invertTree(TreeNode root) { if(root!=null) { TreeNode A=root.left; root.left=root.right; root.right=A; invertTree(root.left); invertTree(root.right); } return root; }}

转载地址:http://bbuvb.baihongyu.com/

你可能感兴趣的文章
java项目之——坦克大战06
查看>>
java项目之——坦克大战09
查看>>
java项目之——坦克大战10
查看>>
java项目之——坦克大战11
查看>>
阿狸面经(牛客网)
查看>>
周总结——第一周(9月5号到9月12)
查看>>
2017招商银行笔试01
查看>>
坦克项目总结
查看>>
设计模式之——单例模式
查看>>
ArrayList、Linkedlist和Vector
查看>>
条理性搭建SSH框架
查看>>
整合Struts和Spring
查看>>
Hibernate和Spring的整合
查看>>
我的校招——同花顺
查看>>
Ego Surfing = Ego + Surfing
查看>>
13日cnblog会谈摘要
查看>>
MoreGoogle提供的网页缩略图服务
查看>>
每天到REFERER到我的网站上来的主页上去溜达一下
查看>>
北京羽毛球场地预定电话
查看>>
本周CNBlog例会:Grassland搜索的后台迁移
查看>>