Problem Description:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit...
                            
                            
                                分类:
其他好文   时间:
2014-07-07 16:05:24   
                                阅读次数:
229
                             
                         
                    
                        
                            
                            
                                Problem Description:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit...
                            
                            
                                分类:
其他好文   时间:
2014-07-07 15:24:41   
                                阅读次数:
212
                             
                         
                    
                        
                            
                            
                                Problem Description:Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most...
                            
                            
                                分类:
其他好文   时间:
2014-07-07 15:24:05   
                                阅读次数:
206
                             
                         
                    
                        
                            
                            
                                Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a...
                            
                            
                                分类:
其他好文   时间:
2014-07-07 08:19:36   
                                阅读次数:
151
                             
                         
                    
                        
                            
                            
                                将Best Time to Buy and Sell Stock的如下思路用到此题目思路1:第i天买入,能赚到的最大利润是多少呢?就是i + 1 ~ n天中最大的股价减去第i天的。思路2:第i天买出,能赚到的最大利润是多少呢?就是第i天的价格减去0~ i-1天中最小的。和前两道题比起来的话,这道题最...
                            
                            
                                分类:
其他好文   时间:
2014-07-06 23:40:44   
                                阅读次数:
284
                             
                         
                    
                        
                            
                            
                                Given a log of stock prices compute the maximum possible earning.
                            
                            
                                分类:
其他好文   时间:
2014-07-06 20:04:21   
                                阅读次数:
259
                             
                         
                    
                        
                            
                            
                                题目
Say you have an array for which the ith element is the price of a given stock on day i.
If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the...
                            
                            
                                分类:
其他好文   时间:
2014-07-03 17:51:01   
                                阅读次数:
235
                             
                         
                    
                        
                            
                            
                                需要注意的是,可以操作两次买卖,但是第二次买入必须在第一次卖出之后才能操作。所以思路就是先正序使用贪心计算每一天之前买入卖出可能达到的最大收益,拿数组记录下来。再逆序计算每一天对应的之后买入卖出可能达到的最大收益,拿数组记录下来。然后将两个数组中每一天对应的两种情况可以实现的收益之和,得到最大值即为可以实现的最大收益。code如下:...
                            
                            
                                分类:
其他好文   时间:
2014-06-27 23:44:49   
                                阅读次数:
247
                             
                         
                    
                        
                            
                            
                                题目#include//最长上升子序列 nlogn//入口参数:数组名+数组长度,类型不限,结构体类型可以通过重载运算符实现//数组下标从1号开始。int bsearch(int a[],int len,int num){ int left=1,right=len; while(left...
                            
                            
                                分类:
其他好文   时间:
2014-06-26 16:20:12   
                                阅读次数:
236
                             
                         
                    
                        
                            
                            
                                动态规划poj3903详解,STL 的lower_bound运用...
                            
                            
                                分类:
其他好文   时间:
2014-06-26 10:25:10   
                                阅读次数:
660