原题链接:https://leetcode.com/problems/house-robber/题意描述:You are a professional robber planning to rob houses along a street. Each house has a certain amo...
分类:
其他好文 时间:
2015-04-06 18:27:43
阅读次数:
132
https://leetcode.com/problems/palindrome-partitioning/Given a strings, partitionssuch that every substring of the partition is a palindrome.Return all...
分类:
其他好文 时间:
2015-04-06 15:23:49
阅读次数:
112
题目链接:https://leetcode.com/problems/majority-element/官方的Solution:Runtime: O(n2) — Brute force solution: Check each element if it is the majority elemen...
分类:
其他好文 时间:
2015-04-06 14:06:30
阅读次数:
115
题目链接:https://leetcode.com/problems/single-number-ii/题意表明有一个数字出现了一次,其他数字出现了三次,那么实现一个模3的计数器即可。 1 class Solution 2 { 3 public: 4 int singleNumber(int...
分类:
其他好文 时间:
2015-04-06 12:49:26
阅读次数:
152
题目链接:https://leetcode.com/problems/binary-tree-preorder-traversal/(非递归实现)二叉树的先序遍历。 1 class Solution 2 { 3 public: 4 vector preorderTraversal(TreeN...
分类:
其他好文 时间:
2015-04-05 23:31:23
阅读次数:
144
https://leetcode.com/problems/simplify-path/Given an absolute path for a file (Unix-style), simplify it.Given an absolute path for a file (Unix-style)...
分类:
其他好文 时间:
2015-04-05 23:29:44
阅读次数:
193
题目链接:https://leetcode.com/problems/binary-tree-inorder-traversal/(非递归实现)二叉树的中序遍历。 1 class Solution 2 { 3 public: 4 vector inorderTraversal(TreeNod...
分类:
其他好文 时间:
2015-04-05 23:29:30
阅读次数:
149
题目链接:https://leetcode.com/problems/unique-binary-search-trees/从最简单的情况开始考虑:n = 0 :只有“空树”这一种情况。f[0]= 1。n = 1 :只有“根节点”这一种情况。f[1]= 1。n = 2 :由于“根节点”必须存在,所以...
分类:
其他好文 时间:
2015-04-05 23:28:47
阅读次数:
171
题目链接:https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/当 k ≥ prices.size()/ 2 时:题目等价于 k 无限大的情形。当 k < prices.size()/ 2 时:用dp[m][n+1]表示在[...
分类:
其他好文 时间:
2015-04-05 23:27:12
阅读次数:
161
题目链接:https://leetcode.com/problems/binary-tree-postorder-traversal/(非递归实现)二叉树的后序遍历。 1 class Solution 2 { 3 public: 4 vector postorderTraversal(Tre...
分类:
其他好文 时间:
2015-04-05 23:24:15
阅读次数:
160