[leetcode] Best Time to Buy and Sell Stock
来源:互联网 发布:淘宝有哪些类目 编辑:程序博客网 时间:2024/05/21 07:58
Best Time to Buy and Sell Stock
class Solution {public: int maxProfit(vector<int> &prices) { if(prices.size()<2){ return 0; } int profit=0; int cur_min=prices[0]; for(int i=1;i<prices.size();i++){ profit=max(profit,prices[i]-cur_min);//利润,最大差价 cur_min=min(cur_min,prices[i]);//当前最小值 } return profit; }};
0 0
- 【LeetCode】Best Time to Buy and Sell Stock & Best Time to Buy and Sell Stock
- [LeetCode] [LeetCode]Best Time to Buy and Sell Stock
- 【LeetCode with Python】 Best Time to Buy and Sell Stock
- [LeetCode]Best Time to Buy and Sell Stock
- [LeetCode]Best Time to Buy and Sell Stock II
- LeetCode Best Time to Buy and Sell Stock
- LeetCode Best Time to Buy and Sell Stock II
- LeetCode Best Time to Buy and Sell Stock III
- Leetcode: Best time to buy and sell a stock I
- Leetcode: Best Time to Buy and Sell Stock II
- LeetCode Best Time to Buy and Sell Stock III
- [Leetcode] Best Time to Buy and Sell Stock
- [Leetcode] Best Time to Buy and Sell Stock II
- [Leetcode] Best Time to Buy and Sell Stock III
- LeetCode : Best Time to Buy and Sell Stock II
- [leetcode] Best Time to Buy and Sell Stock
- leetcode 16: Best Time to Buy and Sell Stock III
- LeetCode Best Time to Buy and Sell Stock
- LNK1123: 转换到 COFF 期间失败: 文件无效或损坏( LINK : fatal error LNK1123: failure during conversion to COFF: fi)
- 京东峰值系统设计
- 搭建Java开发环境-Eclipse
- 线程中更新窗口
- linux ps
- [leetcode] Best Time to Buy and Sell Stock
- 第三章 SELECT语句、表达式和子查询
- 《JavaScript DOM编程艺术》笔记
- Matplotlib 在绘画bar时, 鼠标响应点击 bar 的消息
- NOIP2014提高组DAY1题解
- 转:C#编程读取Excel文件,引用Microsoft.Office.Interop.Excel出现的问题
- [leetcode] Best Time to Buy and Sell Stock II
- [leetcode] Best Time to Buy and Sell Stock III
- 为什么没有开通博客啊这是怎么回事啊