首页 > 其他分享 >leetcode-226-easy

leetcode-226-easy

时间:2022-10-19 07:45:25浏览次数:48  
标签:right TreeNode invertTree return easy 226 null root leetcode

Invert Binary Tree
思路一:递归,交换左右。这题比较出名,个人感觉面试的题目和实际工作中遇到的问题还是不太一样的,所以一点准备都不做就跑去面试,答不上来很正常。
一般能力强的人过一遍资料就有大致的知识结构了

public TreeNode invertTree(TreeNode root) {
    if (root == null) return null;

    TreeNode t = root.right;
    root.right = invertTree(root.left);
    root.left = invertTree(t);

    return root;
}

标签:right,TreeNode,invertTree,return,easy,226,null,root,leetcode
From: https://www.cnblogs.com/iyiluo/p/16804877.html

相关文章

  • leetcode-219-easy
    ContainsDuplicateII思路一:for循环遍历,结果超时publicbooleancontainsNearbyDuplicate(int[]nums,intk){intleft=-1;for(inti=0;i<nums......
  • leetcode-448-easy
    思路一:用数组记录publicList<Integer>findDisappearedNumbers(int[]nums){int[]m=newint[nums.length];for(intnum:nums){if(num-1......
  • leetcode-495-easy
    TeemoAttacking思路一:对两个前后攻击序列,完全分类只可能出现两种情况,只要把重叠的时间都减去,就是所求时间。此分类对三个以上的重叠时间依旧成立没有重叠,攻击时间累......
  • [LeetCode] 1700. Number of Students Unable to Eat Lunch
    Theschoolcafeteriaofferscircularandsquaresandwichesatlunchbreak,referredtobynumbers0and1respectively.Allstudentsstandinaqueue.Eachstu......
  • leetcode 380. Insert Delete GetRandom O(1) O(1) 时间插入、删除和获取随机元素 (
    一、题目大意实现RandomizedSet类:RandomizedSet()初始化RandomizedSet对象boolinsert(intval)当元素val不存在时,向集合中插入该项,并返回true;否则,返回false......
  • IDEA必备开发神器之EasyCode
    IDEA必备开发神器之EasyCode目录1、前言2、安装(EasyCode)3、建立数据库4、在IDEA配置连接数据库5、开始生成代码6、pom.xml7、Application.yml8、启动项目1、前......
  • LeetCode 61旋转链表
    LeetCode61旋转链表题目描述:给你一个链表的头节点head,旋转链表,将链表每个节点向右移动k个位置。示例1:输入:head=[1,2,3,4,5],k=2输出:[4,5,1,2,3]示例2:输......
  • Codeforces Round #828 (Div. 3) E1. Divisible Numbers (easy version)(数学/暴力)
    https://codeforces.com/contest/1744/problem/E1题目大意:给定a,b,c,d;让我们选择从(a,b]中选出一个x,在(c,d]中选出一个y;满足(x*y)/(a*b)是一个整数。input51......
  • 如何配置EasyDSS平台参数,让同一直播间实现重复推流?
    EasyDSS视频直播点播平台集视频直播、点播、转码、管理、录像、检索、时移回看等功能于一体,可提供音视频采集、视频推拉流、播放H.265编码视频等功能,分发的视频流可覆盖全终......
  • EasyClick易点云测 http易语言 unexpected end of stream on http:
    1.易语言官方组件构建服务器异常httpGet异常:unexpectedendofstreamon ​​http://24l700q053.51vip.biz/​​…此问题为易语言服务器需要手动构建正常的get请求协议......