码迷,mamicode.com
首页 >  
搜索关键字:best    ( 2208个结果
Problem Best Time to Buy and Sell Stock III
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
Choose the best route(迪杰斯特拉)
通过做这题,发现了自己的问题很大,做题不是贴代码,而是要了解思想;这题考的是有一个起点的集合,求起点集合到一个终点的最短距离,本来想用Floy的但一看map[1000][1000]超时,有向图,逆序建邻接矩阵,这样就成了一个终点到所有点的最短路了。 1 #include 2 #include ...
分类:其他好文   时间:2014-06-29 18:40:11    阅读次数:170
leetcode——Best Time to Buy and Sell Stock III 买卖股票最大收益(AC)
需要注意的是,可以操作两次买卖,但是第二次买入必须在第一次卖出之后才能操作。所以思路就是先正序使用贪心计算每一天之前买入卖出可能达到的最大收益,拿数组记录下来。再逆序计算每一天对应的之后买入卖出可能达到的最大收益,拿数组记录下来。然后将两个数组中每一天对应的两种情况可以实现的收益之和,得到最大值即为可以实现的最大收益。code如下:...
分类:其他好文   时间:2014-06-27 23:44:49    阅读次数:247
HDU 3623 Best Cow Line, Gold(模拟,注意思路,简单)
题目POJ 3617 和 这道题题目一样,只是范围稍稍再小一点。//模拟试试#include#include#includeusing namespace std;char s[30010][2];bool bijiao(int st,int ed){ if(st==ed) re...
分类:其他好文   时间:2014-06-26 16:00:00    阅读次数:201
poj3617 Best Cow Line
POJ3617 Best Cow Line...
分类:其他好文   时间:2014-06-26 13:36:14    阅读次数:206
Jersey中处理POST格式的Best Practice
REST中,我们可以把接受POST请求的方式写成如下的方式:     @POST     @Consumes(MediaType.APPLICATION_JSON)     public Response createProduct(CreateProductJson createProductJson, @Context UriInfo uriInfo) { CreatePr...
分类:其他好文   时间:2014-06-26 13:30:59    阅读次数:232
celery最佳实践
作为一个Celery使用重度用户,看到Celery Best Practices这篇文章,不由得菊花一紧。干脆翻译出来,同时也会加入我们项目中celery的实战经验。通常在使用Django的时候,你可能需要执行一些长时间的后台任务,没准你可能需要使用一些能排序的任务队列,那么Celery将会是一个非常好的选择。当把Celery作为一个任务队列用于很多项目中后,作者积累了一些最佳实践方式,譬如如何用...
分类:其他好文   时间:2014-06-26 07:18:06    阅读次数:274
Leetcode Best Time to Buy and Sell Stock
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 one transaction (ie...
分类:其他好文   时间:2014-06-25 13:06:16    阅读次数:198
Leetcode Best Time to Buy and Sell Stock II
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-06-25 12:59:40    阅读次数:202
POJ 3617 Best Cow Line 贪心
题解 题目要求是,有两种操作,从头取出一个字符,或者从尾取出一个字符,加到一个新的字符串末端,然后保证这个字符串是所有可能生成的字符串中,字典序排列最小的那个。依旧是贪心的想法,谁小我取谁即可。特殊判断两者相同的。一旦两者相同,那么就接着判断下一种,直到找到更小的为止。 另外需要注意两点,题目的输入很变态,要一个字母一行的输入,所以用cin或者用scanf(" %c", &ch)。cin不多说了,除了慢点其他没啥缺点。scanf中为何要加上一个空格呢?因为在格式串中,空格的意思是匹配输入中的所有换行、TAB...
分类:其他好文   时间:2014-06-25 08:46:12    阅读次数:243
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!