Recursive.class Solution { public: bool isSymmetric(TreeNode *pl, TreeNode *pr) { if (!pl && !pr) return true; if ((pl && !pr)...
分类:
其他好文 时间:
2014-07-22 00:36:36
阅读次数:
197
原来有一些VS2013的工程文件(.sln、.csproj),使用.Net 4.0。现需要将它们转换成VS2010格式。经实验,办法如下:(1) 在Solution文件(.sln)中:把文件头部这样的行:Microsoft Visual Studio Solution File, Format Ve...
分类:
其他好文 时间:
2014-07-22 00:35:35
阅读次数:
195
The trick is, we can work on a reversed vector - learnt from EPI.class Solution {public: vector plusOne(vector &digits) { std::reverse(digit...
分类:
其他好文 时间:
2014-07-22 00:33:36
阅读次数:
223
DFS and using stack to validate candidates.class Solution {public: bool isValid(const string &s) { stack stk; for (int i = 0; i &...
分类:
其他好文 时间:
2014-07-22 00:28:34
阅读次数:
217
Another recursion problem.class Solution {public: int getHeight(TreeNode *p) { if (!p) return 0; int hL = 1; if (p->left) h...
分类:
其他好文 时间:
2014-07-21 11:10:03
阅读次数:
180
Classic recursion\pruning problem. We can use O(n) space: A[i] = j means [i,j] is occupied.class Solution {public: int ret; bool isValid(int *A,...
分类:
其他好文 时间:
2014-07-21 11:08:20
阅读次数:
240
Simply care about the boundary cases:class Solution {public: ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) { if (l1 && !l2) return l1;...
分类:
其他好文 时间:
2014-07-21 11:07:04
阅读次数:
206
Very classic problem. You can brush up your DP and Searching skills.DP:class Solution {public: int maxSubArray(int A[], int n) { // dp[i + 1...
分类:
其他好文 时间:
2014-07-21 11:06:21
阅读次数:
216
public class Solution { public String reverseWords(String s) { String ans=reverse(s); String s2[]=ans.split("\\s+"); ...
分类:
其他好文 时间:
2014-07-21 08:20:33
阅读次数:
203
简单的二叉树的先根遍历模板的应用
class Solution:
# @param root, a tree node
# @return an integer
def hehe(self, num, root):
#再原来的基础上*10,再加上当前的root.val
num = num * 10 + root.val
...
分类:
其他好文 时间:
2014-07-20 22:45:33
阅读次数:
299