No.97 IsInterleave 交错字符串

题目

  • 给定三个字符串 s1, s2, s3, 验证 s3 是否是由 s1s2 交错组成的。

示例

输入: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac"
输出: true

输入: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbbaccc"
输出: false

思路

代码

No.98 IsValidBST 验证二叉搜索树

题目

  • 给定一个二叉树,判断其是否是一个有效的二叉搜索树。
  • 假设一个二叉搜索树具有如下特征:
  • 节点的左子树只包含小于当前节点的数。
  • 节点的右子树只包含大于当前节点的数。
  • 所有左子树和右子树自身必须也是二叉搜索树。

示例

输入:
2
/ \
1 3
输出: true

输入:
5
/ \
1 4
  / \
  3 6
输出: false
解释:
输入为: [5,1,4,null,null,3,6]。
根节点的值为 5 ,但是其右子节点值为 4 。

思路

代码

No.99 RecoverTree 恢复二叉搜索树

题目

  • 二叉搜索树中的两个节点被错误地交换。
  • 请在不改变其结构的情况下,恢复这棵树。

示例

输入: [1,3,null,null,2]

   1
  /
 3
  \
  2 输出: [3,1,null,null,2]   3
  /
 1
  \
  2

输入: [3,1,4,null,null,2]

  3
/ \
1 4
  /
  2 输出: [2,1,4,null,null,3] 2
/ \
1 4
  /
 3

  • 进阶:
  • 使用 O(n) 空间复杂度的解法很容易实现。
  • 你能想出一个只使用常数空间的解决方案吗?

思路

代码

LeetCode No.97,98,99的更多相关文章

  1. 【一天一道LeetCode】#97. Interleaving String

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

  2. LeetCode(97) Interleaving String

    题目 Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example, Given: ...

  3. LeetCode(97):交错字符串

    Hard! 题目描述: 给定三个字符串 s1, s2, s3, 验证 s3 是否是由 s1 和 s2 交错组成的. 示例 1: 输入: s1 = "aabcc", s2 = &qu ...

  4. S11 day 97 -98天 Luffycity项目

    1. 建模 from django.db import models from django.contrib.contenttypes.fields import GenericForeignKey, ...

  5. 【LeetCode】97. Interleaving String

    Interleaving String Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. Fo ...

  6. LeetCode题目解答

    LeetCode题目解答——Easy部分 Posted on 2014 年 11 月 3 日 by 四火 [Updated on 9/22/2017] 如今回头看来,里面很多做法都不是最佳的,有的从复 ...

  7. LeetCode面试常见100题( TOP 100 Liked Questions)

    LeetCode面试常见100题( TOP 100 Liked Questions) 置顶 2018年07月16日 11:25:22 lanyu_01 阅读数 9704更多 分类专栏: 面试编程题真题 ...

  8. linux下生成00 01 02..99的这些数

    [root@localhost ~]# seq -s " " -w 9901 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 ...

  9. 【音乐欣赏】《99》 - MOB CHOIR

    曲名:99 作者:MOB CHOIR [00:00.000] 作曲 : 佐々木淳一 [00:00.150] 作词 : 佐々木淳一 [00:00.450] [00:02.370]If everyone ...

随机推荐

  1. 简单模拟B1011

    #include<iostream> using namespace std; int main() { int n; long long a,b,c; cin >> n; ; ...

  2. JXCPC 试题册

    JXCPC 试题册 Input file: standard input Output file: standard output Time limit: 1s Memory limit: 256 m ...

  3. docker安装fastdfs与java客户端测试

    一.docker 安装FastDFS 1.拉取镜像 docker pull morunchang/fastdfs 2.创建并启动tracker容器 docker run -d --name=track ...

  4. 网页时不时打不开?试试阿里DNS 233.5.5.5 /233.6..6.6

    最经上网都是用手机热点,但发现用谷歌浏览器时,时不时打不开网页.最后发现是DNS的问题,原来我的dns是8.8.8.8. 最后更改成阿里的DNS 233.5.5.5 /233.6..6.6,打开网页流 ...

  5. Python笔记_第四篇_高阶编程_正则表达式_1.正则表达式简介(re模块)

    1. 从一个判断手机号的问题引入: 如果给你一个字符串,去判断是否是一个手机号码,我们通过之前的学习可以有如下代码: # 如果用普通的方式去检验一个电话号码非常麻烦. def checkPhone(s ...

  6. Ubuntu的奇技淫巧

    sudo apt-get install cmatrix 输入密码,安装后,按F11把terminal全屏,输入cmatrix -b sudo apt-get install sl 安装后执行sl,屏 ...

  7. MySQL主主、主从、从从配置文件

    主配置文件: [root@sun01 ~]# more /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql. ...

  8. 调用支付宝接口的简单demo

    依赖: <!-- alipay-sdk-java 注意一下版本--> <dependency> <groupId>com.alipay.sdk</groupI ...

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

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

  10. 阿里云服务器下安装配置phpMyAdmin

    1.下载phpMyAdmin wget http://www.phpmyadmin.net/home_page/downloads.php 2.解压下载的文件 tar -zvxf phpMyAdmin ...