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. python 字符串是否包含某个子字符串

    方法如下:以后再整理 if str1 in str2: 包含的话,True if str1.find(str2)>=0: 包含的话,返回第一次出现的位置,没有的话为负数 https://www. ...

  2. arcgis计算X坐标值、Y坐标值

    arcgis计算X坐标值.Y坐标值 要计算的字段上点击右键,选择计算几何,弹出计算几何对话框.可以设置属性.坐标系.单位等.

  3. java把带小数点的字符串转换成int类型

    String number ="1.0000"; int num =Double.valueOf(number).intValue();//转换为Int类型

  4. 第二十五篇 玩转数据结构——链表(Linked List)

          1.. 链表的重要性 我们之前实现的动态数组.栈.队列,底层都是依托静态数组,靠resize来解决固定容量的问题,而"链表"则是一种真正的动态数据结构,不需要处理固定容 ...

  5. 矩阵快速幂+概率DP poj 3744

    题意:在一条不满地雷的路上,你现在的起点在1处.在N个点处布有地雷,1<=N<=10.地雷点的坐标范围:[1,100000000]. 每次前进p的概率前进一步,1-p的概率前进1-p步.问 ...

  6. python 第三方库安装

    1.首先安装pip 2.在cmd中找到pip的安装路径,(一般在python的scripts文件中) 3.pip install 第三方库名称

  7. Docker - 容器的 连接 与 退出

    概述 连接容器, 退出容器 命令 run exec attach 退出 选项 -i -t -d 1. docker run 概述 docker run 通常用来创建新容器 docker run 的 三 ...

  8. 【音乐欣赏】《PANTA RHEI》 - MYTH & ROID

    曲名:PANTA RHEI 作者:MYTH & ROID [ti:PANTA RHEI (<异世界超能魔术师>TV动画片头曲)] [ar:MYTH & ROID] [al: ...

  9. Atcoder Beginner Contest151E(排列组合)

    排列组合 #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ]; ; ]; long lo ...

  10. BT详解,BT原理

    请参考以下链接: https://www.cnblogs.com/EasonJim/p/6601146.html