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. SAP_SD常用事务代码

    1.创建/修改/显示销售订单:VA01/VA02/VA03 2.根据销售订单创建交货单:VL01N 3.修改/显示交货单:VL02N/VL03N 4.交货单发货过账:VL02N 5.发货过账冲销:VL ...

  2. openstack trove 数据库镜像构建列表

    文件位置:/trove/integration/scripts/files/elements ubuntu@ubuntu:~/Downloads/trove/integration/scripts/f ...

  3. h5-多列布局

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. 深入分析解决Deepin 15环境变量修改问题,完成JAVA环境搭建

    最近使用deepin配置JAVA环境时发现不论是修改/etc/profile还是 ~/.profile多次尝试后均无效,不得其解,最后通过官方论坛看到大神对deepin环境配置的解释,以及寻找到相关解 ...

  5. ADFS 4.0 证书更新

    ADFS 4.0 证书更新 由于公网证书的过期,需要重新更新ADFS的服务通信证书: 证书要求: 带私钥 PFX格式 更换流程: 证书安装到 证书\计算机\个人,安装后点开证书能看到"你有一 ...

  6. 201612-2 工资计算 Java

    思路: 税+税后所得A=税前工资S. 因为工资是整百的数,每次减100来判断.好理解但是超时. import java.util.Scanner; //只有90分,超时了 public class M ...

  7. PAT 2011 秋

    A : World Cup Betting #include <cstdio> #include <iostream> #include <algorithm> u ...

  8. Python-django入门

    上网流程: Django的安装

  9. 异常依然执行{try..catch语句块..}的后续代码

    测试异常依然执行{try..catch语句块..}的后续代码: private static Integer testThrows() throws Exception{ Integer result ...

  10. vue验证时间范围

    验证时间范围 type="daterange" <DatePicker class="formItem" :size="size" v ...