###题目 121. Best Time to Buy and Sell Stock ###解题方法 用一个变量minprice记录当前已经遍历过的最小价格,再用一个变量maxprofit记录当前已经遍历过的最大利润,如果price[i] > minprice,就计算最大利润是否需要增加;否则计算最 ...
分类:
其他好文 时间:
2020-10-21 21:19:48
阅读次数:
21
自己想了好一会,AC后看了下好像和网上挺多人思路不太一样(但本质是一样的),所以就来写这篇题解 首先这题之所以能反悔的根本原因和性质在于你在第i天买股票,第j天卖出,可以拆成第i天买股票,第k(i <= k <= j)天卖出和第k天买股票,第j天卖出两个过程(I) 我们首先可以从大到小倒序扫描,假设 ...
分类:
其他好文 时间:
2020-09-03 17:04:38
阅读次数:
37
这节讲一下线程安全的例子,以及如何解决线程安全问题。 上节提到了线程安全的问题,说了一个例子,1000个人抢100张票,这节就从此案例着手,下面先看一下代码实现: private static int tickets = 100; static void Main(string[] args) { ...
分类:
编程语言 时间:
2020-08-08 17:32:24
阅读次数:
80
JDK动态代理源码分析 动态代理一般常用有两种实现方式:JDK和CGLIB 案例 public class DynamicProxyTestByJDK { public static void main(String[] args) { Buy buy = new BuyImpl(); Buy pr ...
分类:
其他好文 时间:
2020-07-28 16:57:12
阅读次数:
58
package LeetCode_122 /** * 122. Best Time to Buy and Sell Stock II * https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/description/ * * ...
分类:
其他好文 时间:
2020-07-19 18:07:26
阅读次数:
79
动态代理 package test; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; //被代理类接口 interface Buy ...
分类:
其他好文 时间:
2020-07-16 21:56:05
阅读次数:
67
Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tick ...
分类:
其他好文 时间:
2020-06-30 09:15:20
阅读次数:
87
题目: Jesus, what a great movie! Thousands of people are rushing to the cinema. However, this is really a tuff time for Joe who sells the film tickets. ...
分类:
其他好文 时间:
2020-06-24 19:34:23
阅读次数:
52
I am looking to buy best Star Diagnostic tool with dts monaco and vediamo, but there are a few options. Please look at this table, you will find these ...
分类:
其他好文 时间:
2020-06-23 10:28:58
阅读次数:
78
121. Best Time to Buy and Sell Stock ...
分类:
其他好文 时间:
2020-06-21 19:45:07
阅读次数:
45