Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path betwe ...
分类:
其他好文 时间:
2018-10-11 13:41:53
阅读次数:
156
Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target. E ...
分类:
其他好文 时间:
2018-10-11 12:58:51
阅读次数:
181
1,首先,limit_req和limit_conn两个模块都是为了来限流的,但是两者不在一个层面,为了搞清楚这个,必须先要弄清楚request和connection的区别,因为在很多情况下,我们把他们混淆了。 so, what is the difference between connection ...
分类:
其他好文 时间:
2018-10-11 12:57:51
阅读次数:
316
https://leetcode.com/problems/binary-tree-tilt/description/ 挺好的一个题目,审题不清的话很容易做错。主要是tilt of whole tree 的定义是sum of all node's tilt 而不是想当然的tilt of root. ...
分类:
其他好文 时间:
2018-10-11 12:20:11
阅读次数:
100
// string 转 数字很简单,-‘0’就行,数字转string 要用to_string(),是个比较好的函数,网上用的sprintf之类的都丑哭了。class Solution { public: string addBinary(string a, string b) { int lena ... ...
分类:
其他好文 时间:
2018-10-11 11:29:06
阅读次数:
110
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. Example: Input: [ ["1","0","1"," ...
分类:
其他好文 时间:
2018-10-11 10:24:58
阅读次数:
112
二分搜索是一种在有序数组中寻找目标值的经典方法,也就是说使用前提是『有序数组』。非常简单的题中『有序』特征非常明显,但更多时候可能需要我们自己去构造『有序数组』。下面我们从最基本的二分搜索开始逐步深入。 一、lower/upper bound 定义 lower bound 为在给定升序数组中大于等于 ...
分类:
其他好文 时间:
2018-10-10 17:18:57
阅读次数:
190
题目描述 给定一个二叉树,检查它是否是镜像对称的。 例如,二叉树 [1,2,2,3,4,4,3] 是对称的。 但是下面这个 [1,2,2,null,3,null,3] 则不是镜像对称的: 说明: 如果你可以运用递归和迭代两种方法解决这个问题,会很加分。 解题思路 本题可用递归和迭代两种做法来求解。 ...
分类:
其他好文 时间:
2018-10-10 16:05:57
阅读次数:
153
Invert a binary tree. Example: Input: Output: ...
分类:
其他好文 时间:
2018-10-10 14:32:45
阅读次数:
113
哔了狗,一直忘记vector开辟空间以后会把所有元素的地址进行变动,然后疯狂debug ...
分类:
其他好文 时间:
2018-10-09 22:44:56
阅读次数:
215