Problem Description:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.Solution: 递归。 1 public List>...
分类:
其他好文 时间:
2014-07-07 16:59:12
阅读次数:
169
Problem Description:Sort a linked list using insertion sort.Solution: 1 public class Solution { 2 public ListNode insertionSortList(ListNode head)...
分类:
其他好文 时间:
2014-07-07 16:57:55
阅读次数:
117
class Solution {public: bool isPalindrome(string s) { int len = s.length(); //if (len -1 && !(b = check2lower(s[q])) ); i...
分类:
其他好文 时间:
2014-06-30 13:43:33
阅读次数:
178
class Solution {public: int minPathSum(vector > &grid) { int rows = grid.size(); if (rows pathsum(cols + 1, INT_MAX); pathsum...
分类:
其他好文 时间:
2014-06-30 13:23:04
阅读次数:
153
class Solution {private: vector > res;public: vector > combine(int n, int k) { res.clear(); vector path; dfs(1, n, k, path)...
分类:
其他好文 时间:
2014-06-30 12:49:12
阅读次数:
205
今天折腾了四个小时才把这个正确安装上,特此记录下。特别感谢群友的支持。在VMware上新安装了Debain7.5,具体细节不复述了。一、更新系统#apt-get update#apt-get upgrade二、构建编译环境#apt-get install build-essential#apt-ge...
分类:
其他好文 时间:
2014-06-30 12:38:53
阅读次数:
247
Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.Solution:public class Solution { public ...
分类:
其他好文 时间:
2014-06-30 12:18:25
阅读次数:
255
【题目】
Given a binary tree, return the postorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [3,2,1].
Note: Recursive solution is trivial, could you do it iteratively?
【题意】
非递归实现后续遍...
分类:
其他好文 时间:
2014-06-30 10:10:10
阅读次数:
177
【题目】
Given a binary tree, return the preorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [1,2,3].
Note: Recursive solution is trivial, could you do it iteratively?
【题意】
非递归返回先序遍历...
分类:
其他好文 时间:
2014-06-30 06:21:18
阅读次数:
334
题目
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.
Follow up:
Did you use extra space?
A straight forward solution using O(mn) space is probab...
分类:
其他好文 时间:
2014-06-30 06:17:09
阅读次数:
245