码迷,mamicode.com
首页 >  
搜索关键字:solution    ( 11547个结果
Generate Parentheses
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
LeetCode Simplify Path
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
Subsets
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
leetcode -- Add Binary
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
[leetcode]Subsets @ Python
原题地址: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
leetcode -- Best Time to Buy and Sell Stock
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
leetcode -- Best Time to Buy and Sell Stock II
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
Leetcode: Best Time to Buy and Sell Stock II
一次过,思路是:最大收益可以由所有上升序列差价叠加中获得 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
LeetCode ClimbingStairs
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
LeetCode Permutation Sequence
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
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!