leetcode icon indicating copy to clipboard operation
leetcode copied to clipboard

LeetCode题解,151道题完整版。广告:推荐刷题网站 https://www.lintcode.com/?utm_source=soulmachine

Results 51 leetcode issues
Sort by recently updated
recently updated
newest added

`for (int i = 0; i < n; ++i) max_profit = max(max_profit, f[i] + g[i]);` I think `i` would better range from `0` to `n-1` `[0, n-1)` Because the case...

相关问题更正: https://leetcode.com/problems/validate-binary-search-tree/ 题目描述更新:https://leetcode.com/problems/two-sum/
 UPDATE (2016/2/13): The return format had been changed to zero-based indices. Please read the above updated description carefully.

_解题思路: 递归 这道题没什么特别的地方,现在这里简单的分析一下解题思路,从根节点往下,我们要判断三个条件. 1. 左右两个节点的大小是否相同. 2. 左节点的左孩子是否和右节点的右孩子相同. 3. 左节点的右孩子是否和右节点的左孩子相同. ,如果以上**三个条件对于每一层都满足,我们就可以认为这棵树是镜像树**._ 但这并不是树是对称树的所有条件,比如 1 / \ 2 2 / \ / \ 1 2 2 1 / \ / \ / \...

解决了超时的问题。应该使用multi-pass来两两merge

I do not think the time complexity of your code is O (n) but I am not sure what it should be.

The wrong description of Symmetric Tree is copied from Same Tree. I updated it to the correct description.

N 个节点的 BST 的形态为 Catalan 数的第 N 项,即 C(2n, n) / (n + 1) => (2n)! / n! / (n + 1),最后可以写成这样: ``` C++ class Solution { public: int numTrees(int...