一、题目 1、审题 2、分析 给出一个数组,让你先已 val1 买入,再 以 val2 卖出,求获得的利润最大是多少。 二、解答 1、思路: 方法一、 用遍历 min 记录到当前位置的最小值; max 记录到当前数组值的价格卖出为止时获得的最大利润。 优化: 变量 minPrice 直接记录当前的最 ...
分类:
其他好文 时间:
2018-10-06 23:07:20
阅读次数:
148
1、介绍react-router-dom https://reacttraining.com/react-router/web/example/basic 这个官网有很多栗子可以练手 1.1 HashRouter 和BrowserRouter HashRouter 只能有一个子节点 1.2 Rout ...
分类:
其他好文 时间:
2018-10-06 21:37:37
阅读次数:
299
from utils import ( PriorityQueue) import copy infinity = float('inf') def best_first_graph_search(problem, f): #定义初始节点 node = Node(problem.initial) n... ...
分类:
编程语言 时间:
2018-10-06 20:36:34
阅读次数:
267
In a deck of cards, each card has an integer written on it. Return true if and only if you can choose X >= 2 such that it is possible to split the ent ...
分类:
其他好文 时间:
2018-10-06 16:36:18
阅读次数:
168
先来看这道题: USACO 2011 Open Gold Mowing the Lawn 修剪草坪 After winning the annual town competition for best lawn a year ago, Farmer John has grown lazy; he h ...
分类:
其他好文 时间:
2018-10-05 21:56:06
阅读次数:
276
给定一个数组,第i个元素表示第i天股票的价格,只能买卖一次,求最大利润 ...
分类:
其他好文 时间:
2018-10-05 15:00:03
阅读次数:
92
In a deck of cards, each card has an integer written on it. Return true if and only if you can choose X = 2 such that it is possible to split the enti ...
分类:
其他好文 时间:
2018-10-05 14:06:10
阅读次数:
204
只需要遍历一次数组,用一个变量记录遍历过数中的最小值,然后每次计算当前值和这个最小值之间的差值最为利润,然后每次选较大的利润来更新。当遍历完成后当前利润即为所求,代码如下: ...
分类:
其他好文 时间:
2018-10-05 13:48:41
阅读次数:
171
我对二分的理解: "https://www.cnblogs.com/AKMer/p/9737477.html" 题目传送门: "http://poj.org/problem?id=2018" 我们二分一个平均数,设$a$数组每个数减去平均数为$b$数组,若$b$数组当中存在某一段长度大于$k$并且这 ...
分类:
其他好文 时间:
2018-10-05 12:13:11
阅读次数:
177
RESTful API 最佳实践http://www.ruanyifeng.com/blog/2018/10/restful-api-best-practices.htmlRESTful API 设计指南http://www.ruanyifeng.com/blog/2014/05/restful_a ...