No.103 ZigzagLevelOrder 二叉树的锯齿形层次遍历

题目

  • 给定一个二叉树,返回其节点值的锯齿形层次遍历。(即先从左往右,再从右往左进行下一层遍历,以此类推,层与层之间交替进行)。

示例

  • 给定二叉树 [3,9,20,null,null,15,7],
    3
/ \
9 20
/ \
15 7
  • 返回锯齿形层次遍历如下:
[
[3],
[20,9],
[15,7]
]

思路

代码

No.104 MaxDepth 二叉树的最大深度

题目

  • 给定一个二叉树,找出其最大深度。
  • 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。
  • 说明:叶子节点是指没有子节点的节点。

示例

  • 给定二叉树 [3,9,20,null,null,15,7]
    3
/ \
9 20
/ \
15 7
  • 返回它的最大深度 3 。

思路

代码

No.105 BuildTree 从前序与中序遍历序列构造二叉树

题目

  • 根据一棵树的前序遍历与中序遍历构造二叉树。
  • 注意:你可以假设树中没有重复的元素。

示例

  • 例如,给出
前序遍历 preorder = [3,9,20,15,7]
中序遍历 inorder = [9,3,15,20,7]
  • 返回如下的二叉树:
    3
/ \
9 20
/ \
15 7

思路

代码

LeetCode No.103,104,105的更多相关文章

  1. leetCode :103. Binary Tree Zigzag Level Order Traversal (swift) 二叉树Z字形层次遍历

    // 103. Binary Tree Zigzag Level Order Traversal // https://leetcode.com/problems/binary-tree-zigzag ...

  2. 【一天一道LeetCode】#103. Binary Tree Zigzag Level Order Traversal

    一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 来源: htt ...

  3. LeetCode(103): 二叉树的锯齿形层次遍历

    Medium! 题目描述: 给定一个二叉树,返回其节点值的锯齿形层次遍历.(即先从左往右,再从右往左进行下一层遍历,以此类推,层与层之间交替进行). 例如:给定二叉树 [3,9,20,null,nul ...

  4. LeetCode(103) Binary Tree Zigzag Level Order Traversal

    题目 Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left ...

  5. [LeetCode&Python] Problem 104. Maximum Depth of Binary Tree

    Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...

  6. [leetcode tree]103. Binary Tree Zigzag Level Order Traversal

    Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to ...

  7. 【LeetCode】103. Binary Tree Zigzag Level Order Traversal

    Binary Tree Zigzag Level Order Traversal Given a binary tree, return the zigzag level order traversa ...

  8. LeetCode 中级 - 组合总和(105)

    给定一个无重复元素的数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合. candidates 中的数字可以无限制重复被选 ...

  9. LeetCode 简单 -二进制求和(105)

    给定两个二进制字符串,返回他们的和(用二进制表示). 输入为非空字符串且只包含数字 1 和 0. 示例 1: 输入: a = "11", b = "1" 输出: ...

随机推荐

  1. ODBC OLEDB

    ODBC  OLEDB https://www.cnblogs.com/dachuang/p/8615754.html

  2. tensorflow笔记2(北大网课实战)

    1.正则化缓解过拟合 正则化在损失函数中引入模型复杂度指标,利用给w加权值,弱化了训练数据的噪声 一般不会正则化b. 2.matplotlib.pyplot 3.搭建模块化的神经网络八股: 前向传播就 ...

  3. 图片分割之GrabCut算法、分水岭算法

    https://www.cnblogs.com/zyly/p/9392881.html 所谓图像分割指的是根据灰度.颜色.纹理和形状等特征把图像划分成若干互不交迭的区域,并使这些特征在同一区域内呈现出 ...

  4. PHP的一个小tips (关于=和==或者===的使用)

    由于我在项目中,很多场景判断等式成立的时候 都习惯把值放在==前面(例如 1 == $nStatus), 今天有个同事揪着我问为啥总这样写,回答之后今天也稍作记录下吧. 如果正常些 $nStatus ...

  5. PAT Advanced 1064 Complete Binary Search Tree (30) [⼆叉查找树BST]

    题目 A Binary Search Tree (BST) is recursively defined as a binary tree which has the following proper ...

  6. 第22章 Makefile基础

    一.自动处理头文件的依赖关系 在Makefile中插入如下代码: include $(sources:.c=.d) %.d: %.c set -e; rm -f $@; \ $(CC) -MM $(C ...

  7. 申请FreeDomain,透过DNS转回自己的Godaddy Cpanel

    148.66.136.216这个IP,是我的Cpanel IP. 过了几分钟,这个kkchan.tk就转到Cpanel了. 然后在Cpanel的Addon Domains加上kkchan.tk,那就可 ...

  8. IDA解析so文件异常(Binary data is incorrect maximum possible value is xx)

    错误信息 Binary data is incorrect maximum possible value is 0 错误原因 so文件损坏 或者ida换成32 解决办法 重新获得so文件,或者调整id ...

  9. spring hystrix和内置tomcat组件的参数调优解析

    1. springboot内置tomcat容器的参数配置 server: port: 12021 # server端的socket超时间(毫秒),使用值-1表示没有(即无限)超时,默认值为60000( ...

  10. 自定义的listbox支持拖放

    unit unit2; interface uses Classes, Controls, StdCtrls; type TListBox2 = class(TCustomListBox) prote ...