Problem
You receive a credit C at a local store and would like to buy two items. You first walk through the store and create a list L of
all available items. From this list you would like to buy tw...
分类:
其他好文 时间:
2014-10-12 12:38:28
阅读次数:
241
问题: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may co...
分类:
其他好文 时间:
2014-10-12 00:58:36
阅读次数:
686
ConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionLindsay is a shopaholic. Whenever there is a discount of the kind where you can buy three...
分类:
其他好文 时间:
2014-10-11 22:47:36
阅读次数:
191
有一组数组代表股票的价格一次买一次卖如何得到最大利润? 1 public int maxProfit(int[] prices) { 2 if(prices.length==0)return 0; 3 int maxProfit=0; 4 in...
分类:
编程语言 时间:
2014-10-11 22:08:36
阅读次数:
174
题目链接:
huangjing
思路:
因为给出了n条插入,所以如果正推的话,那么后面插的会影响到最后所在的位置,所以考虑逆序解决,那么如果此人站在第i个人的位置,那么这个人前面必然有i个空位置没占,因为是从后向前考虑的,所以每次更新的时候就要考虑在前面存在i个空位的位置后插入这个人,那么最后得到的序列就是满足条件的。。
题目:
Language:
Defaul...
分类:
其他好文 时间:
2014-10-10 11:43:04
阅读次数:
238
问题: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may co...
分类:
其他好文 时间:
2014-10-10 00:18:11
阅读次数:
398
Best Time to Buy and Sell Stock I
只能作一次操作时:维护preMin记录之前出现的最小值
代码如下:
int maxProfit(vector &prices) {
if (prices.size() == 0) return 0;
int profit = 0;
int preMin = prices...
分类:
其他好文 时间:
2014-10-10 00:02:08
阅读次数:
204
/**
* Say you have an array for which the ith element is the price of a given stock on day i.
* Design an algorithm to find the maximum profit. You may complete as many transactions as you like
* ...
分类:
其他好文 时间:
2014-10-07 11:10:03
阅读次数:
129
设50元的人为+1 100元的人为-1 满足前任意k个人的和大于等于0 卡特兰数
C(n+m, m)-C(n+m, m+1)*n!*m!
import java.math.*;
import java.util.*;
public class Main {
/**
* @param args
*/
public static void main(Str...
分类:
其他好文 时间:
2014-10-07 00:43:11
阅读次数:
232
原题地址:https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/题意:Say you have an array for which theithelement is the price of a given sto...
分类:
编程语言 时间:
2014-10-06 23:54:02
阅读次数:
266