
leet code
xingkongyidian
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
二叉树专题
一 二叉树遍历 1 先序遍历(pre_order),根左右 2 中序遍历(in_order)左根右 3 后序遍历(post_order)左右根 后序遍历常用于数学计算,如下图 后序遍历这棵树,用堆栈处理表达式。每次遇到操作符时,只需从堆栈中弹出2个元素,计算结果并将结果推回堆栈。 代码实例: 先序遍历 Given a binary tree, return the preorder tra...原创 2018-12-24 18:21:05 · 206 阅读 · 0 评论 -
二叉搜索树
一、 二叉搜索树定义: 二叉搜索树是一种特殊的二叉树,满足以下两个特点: 1 每个节点处的值大于等于其左子树上的值 2 每个节点处的值小于等于其右子树上的值 示例: 中序遍历二叉搜索树树可以得到这些值的升序排序。 判断二叉树是否为二叉搜索树: 1 用递归的思想判断每个节点是否满足定义的两个特点 2 中序遍历二叉树,看是否为升序 方法一: def ValidBST(root, minv, maxv...原创 2019-03-02 18:15:44 · 222 阅读 · 0 评论 -
leetcode Find the Duplicate Number
题目 Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number,...原创 2019-03-15 21:03:37 · 151 阅读 · 0 评论 -
leetcode Median of Two Sorted Arrays
题目: There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). You may assume nums1 and...原创 2019-03-15 21:47:04 · 237 阅读 · 0 评论 -
剑指offer刷题
题目1 孩子们的游戏(圆圈中最后剩下的数)[题目链接](https://www.nowcoder.com/practice/f78a359491e64a50bce2d89cff857eb6?tpId=13&tqId=11199&tPage=3&rp=3&ru=/ta/coding-interviews&qru=/ta/coding-interviews/qu...原创 2019-08-12 21:30:59 · 188 阅读 · 0 评论