No.109 SortedListToBST 有序链表转换二叉搜索树

题目

  • 给定一个单链表,其中的元素按升序排序,将其转换为高度平衡的二叉搜索树。
  • 本题中,一个高度平衡二叉树是指一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过 1。

示例

给定的有序链表: [-10, -3, 0, 5, 9],

一个可能的答案是:[0, -3, 9, -10, null, 5], 它可以表示下面这个高度平衡二叉搜索树:

      0
/ \
-3 9
/ /
-10 5

思路

代码

No.110 IsBalanced 平衡二叉树

题目

  • 给定一个二叉树,判断它是否是高度平衡的二叉树。
  • 本题中,一棵高度平衡二叉树定义为:一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过1。

示例

  • 给定二叉树 [3,9,20,null,null,15,7]
    3
/ \
9 20
/ \
15 7
  • 返回 true

  • 给定二叉树 [1,2,2,3,3,null,null,4,4]
       1
/ \
2 2
/ \
3 3
/ \
4 4
  • 返回 false

思路

代码

No.111 MinDepth 二叉树的最小深度

题目

  • 给定一个二叉树,找出其最小深度。
  • 最小深度是从根节点到最近叶子节点的最短路径上的节点数量。
  • 说明: 叶子节点是指没有子节点的节点。

示例

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

思路

代码

LeetCode No.109,110,111的更多相关文章

  1. 【LeetCode】109. Convert Sorted List to Binary Search Tree 解题报告(Python)

    [LeetCode]109. Convert Sorted List to Binary Search Tree 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id ...

  2. [leetcode] 题解记录 1-10

    博客园markdown太烂, 题解详见https://github.com/TangliziGit/leetcode/blob/master/solution/1-10.md Leetcode Sol ...

  3. LeetCode解题Golang(1-10)

    前言 LeetCode题目个人答案(Golang版) 本篇预期记录 1-10 题, 持续更新 正文 1.两数之和(简单) https://leetcode-cn.com/problems/two-su ...

  4. 【一天一道LeetCode】#109. Convert Sorted List to Binary Search Tree

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

  5. 【leetcode❤python】110. Balanced Binary Tree

    #-*- coding: UTF-8 -*-#平衡二叉树# Definition for a binary tree node.# class TreeNode(object):#     def _ ...

  6. LeetCode OJ 109. Convert Sorted List to Binary Search Tree

    Given a singly linked list where elements are sorted in ascending order, convert it to a height bala ...

  7. 109.110.100.56 samba用户名 PAS, 密码 111111

    如果修改文件夹名字, 需要更改 cd /etc/samba/smb.conf 然后重启samba service smb restart 如果要修改文件夹权限 chmod -R 777 folder ...

  8. LeetCode(109):有序链表转换二叉搜索树

    Medium! 题目描述: 给定一个单链表,其中的元素按升序排序,将其转换为高度平衡的二叉搜索树. 本题中,一个高度平衡二叉树是指一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过 1. 示例: ...

  9. 【Leetcode】109. Convert Sorted List to Binary Search Tree

    Question: Given a singly linked list where elements are sorted in ascending order, convert it to a h ...

随机推荐

  1. Mycat简介及适用场景

    官网:http://www.mycat.io/ 一.Mycat是什么 Mycat是一个开源的分布式数据库系统,是一个实现了 MySQL 协议的的 Server,前端用户可以把它看作是一个数据库代理,用 ...

  2. KAFKA伪集群单机安装

    下载 kafka_2.11-2.0.1.tgz 文档kafka_2.11-2.0.1-site-docs.tgz cd /uae/local tar -zxvf kafka_2.11-2.0.1.tg ...

  3. 【论文笔记系列】AutoML:A Survey of State-of-the-art (下)

    [论文笔记系列]AutoML:A Survey of State-of-the-art (上) 上一篇文章介绍了Data preparation,Feature Engineering,Model S ...

  4. php随机生成国内IP

    public function rand_ip(){ $ip_long = array( array('607649792', '608174079'), //36.56.0.0-36.63.255. ...

  5. [原]调试实战——使用windbg调试DLL卸载时的死锁

    原调试debugwindbg死锁deadlock 前言 最近我们的程序在退出时会卡住,调查发现是在卸载dll时死锁了.大概流程是这样的:我们的dll在加载的时候会创建一个工作线程,在卸载的时候,会设置 ...

  6. PAT甲级——1073 Scientific Notation (20分)

    Scientific notation is the way that scientists easily handle very large numbers or very small number ...

  7. Python 中 JSON和dict的转换,json的使用

    一. 基础语法 在Python 的 json库中,共有四个方法.分别是: json.load() # 从文件中加载 json.loads() # 数据中加载 json.dump() # 转存到文件 j ...

  8. gff文件提取cds

    #!/usr/bin/perl use strict; use warnings; ########input######## ];my $cut = &cut($gff);my %cut = ...

  9. 将keras的h5模型转换为tensorflow的pb模型

    h5_to_pb.py from keras.models import load_model import tensorflow as tf import os import os.path as ...

  10. Lua与C++交互初探之C++调用Lua

    Lua与C++交互初探之C++调用Lua 自从学习了lua这个脚本语言之后,无时不想着将他与c/c++联系起来,看看他真正的威力.奈何水平有限,网上找的代码无论怎样都无法运行成功.我知道是我少了某一步 ...