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 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
Given two binary strings, return their sum
(also a binary string).For example,a ="11"b ="1"Return"100".class Solution
{public: string addBinary(str...
分类:
其他好文 时间:
2014-05-30 08:39:11
阅读次数:
270
原题地址:https://oj.leetcode.com/problems/subsets/题意:枚举所有子集。解题思路:碰到这种问题,一律dfs。代码:class
Solution: # @param S, a list of integer # @return a list of l...
分类:
编程语言 时间:
2014-05-30 04:31:09
阅读次数:
1243
class Solution {public: int maxProfit(vector
&prices) { if(prices.size() == 0) return 0; vector f1(prices.size()); int
minV = pri...
分类:
其他好文 时间:
2014-05-30 02:54:28
阅读次数:
231
class Solution {public: int maxProfit(vector
&prices) { if(prices.size() == 0) return 0; vector f(prices.size()); f[0] =
0; ...
分类:
其他好文 时间:
2014-05-30 02:46:12
阅读次数:
318
一次过,思路是:最大收益可以由所有上升序列差价叠加中获得 1 public class
Solution { 2 public int maxProfit(int[] prices) { 3 int profit = 0; 4 if
(prices.lengt...
分类:
其他好文 时间:
2014-05-29 20:43:33
阅读次数:
254
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