Givennpairs of parentheses, write a function to
generate all combinations of well-formed parentheses.For example, givenn= 3, a
solution set is:"((()))...
分类:
其他好文 时间:
2014-06-04 22:30:30
阅读次数:
418
class Solution {public: string
simplifyPath(string path) { int len = path.length(); if (len spath; int p = -1,
q = 0; ...
分类:
其他好文 时间:
2014-06-04 20:15:49
阅读次数:
197
Given two integersnandk, return all possible
combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution
is:[ [2,4], [3,4], [2,3], [1...
分类:
其他好文 时间:
2014-06-04 20:02:13
阅读次数:
228
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 m...
分类:
其他好文 时间:
2014-06-04 20:01:32
阅读次数:
340
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 ...
分类:
其他好文 时间:
2014-06-03 13:53:21
阅读次数:
309
class Solution {public: ListNode
*mergeKLists(vector &lists) { ListNode* merged = NULL; for (int i=0; ival
val) { n...
分类:
其他好文 时间:
2014-06-03 13:26:43
阅读次数:
219
题目真长。。。。。看了好长时间才看懂。。就是给你一个32位数字和一个最多15个字符的字符串,从字符串中选出5个字符,若满足题中给的那个式子,输出字典序最大的那5个字符,若不满足,输出no
solution。为了解决字典序问题,在输入字符串后,把字符串按从大到小排一下序,搜索一下若满足条件输出即可。贴...
分类:
其他好文 时间:
2014-06-03 13:07:48
阅读次数:
200
class Solution {public: void merge(int A[], int
m, int B[], int n) { int mi = m + n - 1; int ai = m - 1; int bi = n - 1; ...
分类:
其他好文 时间:
2014-06-03 12:57:28
阅读次数:
217
class Solution {public: int climbStairs(int n)
{ if (n < 1) return 0; int a = 0; int b = 1; for (int i=0; i<n; i++) { ...
分类:
其他好文 时间:
2014-05-29 20:23:07
阅读次数:
339
class Solution {public: string
getPermutation(int n, int k) { k--; if (n nums(n, 0); long seg = 1; for (int
i=0; i= se...
分类:
其他好文 时间:
2014-05-29 17:04:51
阅读次数:
209