700 二叉搜索树中的搜索

https://leetcode-cn.com/problems/search-in-a-binary-search-tree

175 组合两个表

表1: Person

+-------------+---------+
| 列名 | 类型 |
+-------------+---------+
| PersonId | int |
| FirstName | varchar |
| LastName | varchar |
+-------------+---------+
PersonId 是上表主键
表2: Address +-------------+---------+
| 列名 | 类型 |
+-------------+---------+
| AddressId | int |
| PersonId | int |
| City | varchar |
| State | varchar |
+-------------+---------+ AddressId 是上表主键

编写一个 SQL 查询,满足条件:无论 person 是否有地址信息,都需要基于上述两表提供 person 的以下信息:FirstName, LastName, City, State

仍旧不理解 left join

select FirstName, LastName, City, State
from Person left join Address
on Person.PersonId = Address.PersonId;

590. N叉树的后序遍历

递归:

这个思路还是 递归的,下面是迭代的提升:

迭代:

思路: 迭代进行了 NRL 的先序 迭代 遍历,然后reverse NRL 到 LRN 就是 要求的后序遍历了啊。ok

589 N叉树的前序遍历

https://leetcode-cn.com/problems/n-ary-tree-preorder-traversal

递归, 注意 递归 过程中附带的 action 的位置

位置在前面,因为是先序(对比上面的后序遍历, 你可以看到后序遍历的 ans.add(root.val) 在后面。

迭代实现,如何正确入栈(倒序children 入栈,才是先序的正确姿势)

为什么先/前序遍历需要 用 stack ,而不是 queue(以及阐明:层序遍历确实需要queue)

leetcode 0205的更多相关文章

  1. 我为什么要写LeetCode的博客?

    # 增强学习成果 有一个研究成果,在学习中传授他人知识和讨论是最高效的做法,而看书则是最低效的做法(具体研究成果没找到地址).我写LeetCode博客主要目的是增强学习成果.当然,我也想出名,然而不知 ...

  2. LeetCode All in One 题目讲解汇总(持续更新中...)

    终于将LeetCode的免费题刷完了,真是漫长的第一遍啊,估计很多题都忘的差不多了,这次开个题目汇总贴,并附上每道题目的解题连接,方便之后查阅吧~ 477 Total Hamming Distance ...

  3. [LeetCode] Longest Substring with At Least K Repeating Characters 至少有K个重复字符的最长子字符串

    Find the length of the longest substring T of a given string (consists of lowercase letters only) su ...

  4. Leetcode 笔记 113 - Path Sum II

    题目链接:Path Sum II | LeetCode OJ Given a binary tree and a sum, find all root-to-leaf paths where each ...

  5. Leetcode 笔记 112 - Path Sum

    题目链接:Path Sum | LeetCode OJ Given a binary tree and a sum, determine if the tree has a root-to-leaf ...

  6. Leetcode 笔记 110 - Balanced Binary Tree

    题目链接:Balanced Binary Tree | LeetCode OJ Given a binary tree, determine if it is height-balanced. For ...

  7. Leetcode 笔记 100 - Same Tree

    题目链接:Same Tree | LeetCode OJ Given two binary trees, write a function to check if they are equal or ...

  8. Leetcode 笔记 99 - Recover Binary Search Tree

    题目链接:Recover Binary Search Tree | LeetCode OJ Two elements of a binary search tree (BST) are swapped ...

  9. Leetcode 笔记 98 - Validate Binary Search Tree

    题目链接:Validate Binary Search Tree | LeetCode OJ Given a binary tree, determine if it is a valid binar ...

随机推荐

  1. Django项目报错: 禁止访问(403),CSRF验证失败,相应中断

    如果想要取消表单的CSRF防护,可以在模板上删除{% csrf_token %}, 并且在相应的视图函数中添加装饰器@csrf_exempt, 代码如下: from django.views.deco ...

  2. Wx-公众号-关闭内置浏览器页面,返回公众号橱窗

    方法一: pushHistory(); function pushHistory() { var state = { title: "title", url: "#&qu ...

  3. jsoup学习待续

    1.Jsoup简介 Jsoup是一个java html解析器.它是一个用于解析HTML文档的java库.Jsoup提供api来从URL或HTML文件中提取和操作数据.它使用DOM,CSS和类似 Jqu ...

  4. 转 C#中哈希表(HashTable)的用法详解

    看了一遍有关哈希表的文字,作者总结的真是不错 .收藏起来 1.  哈希表(HashTable)简述 在.NET Framework中,Hashtable是System.Collections命名空间提 ...

  5. Sql Server跨服务器操作数据

    var serversSql = "select count(*) count from sys.servers WHERE name='ITSV'"; var result = ...

  6. spring jdbcTemplate query 返回值为null

    spring jdbcTemplate query 返回值为null 今天使用以下方法从数据库中查询数据,返回列表 public List<BookBean> getBooks(){ St ...

  7. Codeforces Round #624 (Div. 3) F

    题意: 给出n的质点,带着初位置和速度: 如果中途两点可以相遇dis(i,j)=0: 如果不可以相遇,mindis(i,j): 求n个点的两两质点最小dis(i,j)之和 思路: 因为当初位置x和速度 ...

  8. Docker - 创建第一个 docker 实例

    1. 概述 安装完准备开始使用 2. 环境 os centos 7 docker docker - ce 19.03 3. 步骤 启动docker > systemctl start docke ...

  9. 通过python代码连接MySQL以及插入和显示数据

    通过python代码连接MySQL以及插入和显示数据: 数据库huahui创建一个shibie的表,里面有两个varcahr(100)的字段,num和result. import pymysql im ...

  10. js三种常见的对话框

    js中的对话框事通过调用window对象的alert()  confirm()  和 prompt()来获得,完成人机交互. 1. 警告框alert() function alert(){ // 弹出 ...