# [LeetCode] Best Time to Buy and Sell Stock(Java)

<span style="font-size:24px;">public class Solution {
public int maxProfit(int[] prices) {
if(prices.length == 0)
return 0;
int[] minA = new int[prices.length];
minA[0] = prices[0];
int i = 1,max = 0,temp = 0;
while(i<minA.length){
if(prices[i]<minA[i-1])
minA[i] = prices[i];
else
minA[i] = minA[i-1];
temp = prices[i] - minA[i];
if(temp > max)
max = temp;
i++;
}
return max;
}
}</span>

2016/8/30

#### [leetcode]123. Best Time to Buy and Sell Stock III(Java)

2017-07-15 10:46:54

#### [leetcode]121. Best Time to Buy and Sell Stock(Java)

2017-07-15 09:13:56

#### LeetCode 121. Best Time to Buy and Sell Stock 题解 —— Java

2017-03-20 20:11:21

#### 【leetcode】122. Best Time to Buy and Sell Stock II【java】

2017-01-11 11:31:58

#### 【LeetCode-面试算法经典-Java实现】【121-Best Time to Buy and Sell Stock（最佳买卖股票的时间）】

2015-08-14 06:16:32

#### LeetCode(188) Best Time to Buy and Sell Stock IV (Java)

2015-04-19 15:45:27

#### [leetcode] 309. Best Time to Buy and Sell Stock with Cooldown 解题报告

2016-06-14 14:53:30

#### leetcode【121+122+123 best time to buy and sell stock】【python】

2016-09-12 21:04:35

#### 【LeetCode】 Best Time to Buy and Sell Stock I II III IV 解题报告

2015-04-06 11:10:34