题目:Given a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must n....
分类:
编程语言 时间:
2014-07-31 05:22:45
阅读次数:
286
The only difference with version I is: one number can only be used once:class Solution {public: vector > ret; struct Rec { Rec() : sum...
分类:
其他好文 时间:
2014-07-31 05:22:25
阅读次数:
239
问题描述:
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.
For example,
If n = 4 and k = 2, a solution is:
[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]
解题思路...
分类:
其他好文 时间:
2014-07-31 00:04:35
阅读次数:
204
Two elements of a binary search tree (BST) are swapped by mistake.
Recover the tree without changing its structure.
Note:
A solution using O(n)
space is pretty straight...
分类:
其他好文 时间:
2014-07-30 17:46:04
阅读次数:
244
解法:考虑多种情况 1 #include 2 3 class Solution { 4 public: 5 int atoi(const char *str) { 6 int signal = 0; /*标记正负,还未出现判定正负的标志时,记为0*/ 7 ...
分类:
其他好文 时间:
2014-07-30 11:57:03
阅读次数:
182
题目:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], ...
分类:
编程语言 时间:
2014-07-30 09:58:03
阅读次数:
218
归并排序的链表法#includeusing namespace std;struct ListNode{ int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution{public:...
分类:
其他好文 时间:
2014-07-30 07:40:23
阅读次数:
174
定义一个队栈,每次出现一个数放进栈中,若出现运算符的话,就将栈顶的两个元素出栈进行运算后在放入栈考虑特殊情况1.只有一个数字的时候2.出现负数的情况class Solution{public: int evalRPN(vector &tokens) { // if(token...
分类:
其他好文 时间:
2014-07-30 07:40:03
阅读次数:
169
考虑几个特殊的情况1.若字符窜s=" "2.字符窜s=“a b d e”3.字符窜s=“ a”然后在s后面+上一个‘ ’,每次遇到s[i]为空格,s[i-1]不为空格的时候为一个单词class Solution{public: void reverseWords(string &s) ...
分类:
其他好文 时间:
2014-07-30 07:38:43
阅读次数:
171
在学习nodejs partials view时,怎么都不能运行成功。经过艰苦探索,终于成功了,分享一下。Cause: nodejs 的express 版本之间不是很兼容,各个版本差异很大,一般用npm 默认安装的都是最新版本的express。Solution:partials() 如果要直接在ej...
分类:
Web程序 时间:
2014-07-29 21:29:22
阅读次数:
443