码迷,mamicode.com
首页 >  
搜索关键字:solution upgrade    ( 13024个结果
Peterson和多线程版本
Peterson's algorithm (AKA Peterson's solution) is a concurrent programming algorithm for mutual exclusion that allows two processes to share a single-use resource without conflict, using only shar...
分类:编程语言   时间:2014-06-25 19:38:19    阅读次数:748
LeetCode Reverse Integer
class Solution {public: int reverse(int x) { bool neg = x < 0; long long num = x; if (neg) num = -num; long long out = ...
分类:其他好文   时间:2014-06-25 18:24:01    阅读次数:280
LeetCode Remove Element
class Solution {public: int removeElement(int A[], int n, int elem) { if (A == NULL || n < 1) return 0; int rpos = 0, wpos = 0; ...
分类:其他好文   时间:2014-06-25 17:47:57    阅读次数:234
leetcode--Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.public class Solution { public String longestCommonPrefix(Str...
分类:其他好文   时间:2014-06-25 17:03:03    阅读次数:331
LeetCode 3Sum Closest
class Solution {public: int threeSumClosest(vector &num, int target) { int len = num.size(); if (len target) { q-...
分类:其他好文   时间:2014-06-24 21:22:03    阅读次数:138
【LeetCode】Pow(x, n)
题目 Implement pow(x, n). 解答 直接用递归法: //递归法("折半"递归,不要用常规的一个个乘,效率很低) public class Solution { public double pow(double x, int n) { if(n==0) return 1; if(n==1) ...
分类:其他好文   时间:2014-06-24 21:14:37    阅读次数:199
Reverse Words in a String
【问题】 Given an input string, reverse the string word by word. For example, Given s = "the sky is blue", return "blue is sky the". 【代码】 class Solution: # @param s, a string # @retu...
分类:其他好文   时间:2014-06-24 21:00:30    阅读次数:168
LeetCode:Subsets II
Given a collection of integers that might contain duplicates, S, return all possible subsets. Note: Elements in a subset must be in non-descending order.The solution set must not contain duplica...
分类:其他好文   时间:2014-06-24 20:58:32    阅读次数:230
LeetCode Best Time to Buy and Sell Stock II
class Solution {public: int maxProfit(vector &prices) { int len = prices.size(); if (len < 1) return 0; int sum = 0; in...
分类:其他好文   时间:2014-06-24 11:28:47    阅读次数:193
leetcode -day31 Subsets I II
1、 ?? 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 must not contain duplicate subset...
分类:其他好文   时间:2014-06-22 17:08:53    阅读次数:179
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!