LeetCode刷题笔记(121,买卖股票的最佳时机,Easy)
2020-06-08 05:19
274 查看
[code]class Solution { public int maxProfit(int[] prices) { int minstake = Integer.MAX_VALUE; int maxprofit = 0; for(int i : prices){ if(i < minstake){ minstake = i; } maxprofit = Math.max(maxprofit,i - minstake); } return maxprofit; } }
相关文章推荐
- LeetCode刷题笔记121:买卖股票的最佳时机
- leetcode-121 买卖股票的最佳时机 Python
- LeetCode || 121-124. 买卖股票的最佳时机
- Leetcode121: 买卖股票的最佳时机
- 力扣121题:买卖股票的最佳时机,python实现,学习笔记
- C++Leetcode121:买卖股票的最佳时机
- LeetCode-121.买卖股票的最佳时机(相关话题:动态规划)
- LeetCode题库解答与分析——#121. 买卖股票的最佳时机BestTimeToBuyAndSellStock
- Leetcode121 Best Time to Buy and Sell Stock(买卖股票的最佳时机1)
- Leetcode之121. 买卖股票的最佳时机
- 基础算法之买卖股票最佳时机(Leetcode-121)
- 【leetcode系列】121. 买卖股票的最佳时机
- leetcode-121-买卖股票的最佳时机
- LeetCode 121.买卖股票的最佳时机(一)
- LeetCode 121 买卖股票的最佳时机 Python
- LeetCode:买卖股票的最佳时机 IV
- 【leetcode】买卖股票的最佳时机2
- LeetCode 122 买卖股票的最佳时机2 Python
- leetcode python3 买卖股票的最佳时机 II
- LeetCode刷题指南:买卖股票的最佳时机II