- leetcode:121. Best Time to Buy a
- LeetCode #121 #122 #123 #188 #30
- #121. Best Time to Buy and Sell
- [LeetCode] 121. Best Time to Buy
- Leetcode121 - 123 (dp problems)
- [数组]121. Best Time to Buy and Se
- 121. Best Time to Buy and Sell S
- Leetcode121-Best Time to Buy and
- 每天(?)一道LeetCode(14) Best Time to
- Leetcode 股票合集 【121、122、714、309】
public class Solution {
public int maxProfit(int[] prices) {
if(prices.length==0) return 0;
int max=0,minprice=prices[0];
for(int i=1;i<prices.length;i++){
if(prices[i]>minprice){
max=Math.max(max,prices[i]-minprice);
}else minprice=prices[i];
}
return max;
}
}
网友评论