leetcode 121 Best Time to Buy and Sell Stock C++
来源:互联网 发布:plc编程实例 编辑:程序博客网 时间:2024/05/16 07:33
动态规划
class Solution {public: int maxProfit(vector<int>& prices) { if(prices.size() <= 0) return 0; int minPrice = prices[0]; int maxProfit = 0; for(int i =0 ;i<prices.size();i++){ maxProfit = max(maxProfit,prices[i]-minPrice); minPrice = min(minPrice,prices[i]); } return maxProfit; }};
0 0
- [C++]LeetCode: 54 Best Time to Buy and Sell Stock
- 【C++】【LeetCode】121. Best Time to Buy and Sell Stock
- LeetCode 121: Best Time to Buy and Sell Stock
- LeetCode(121)Best Time to Buy and Sell Stock
- LeetCode 121 Best Time to Buy and Sell Stock
- LeetCode: Best Time to Buy and Sell Stock [121]
- LeetCode 121 Best Time to Buy and Sell Stock
- [leetcode 121] Best Time to Buy and Sell Stock
- Leetcode NO.121 Best Time to Buy and Sell Stock
- LeetCode 121 Best Time to Buy and Sell Stock
- LeetCode(121) Best Time to Buy and Sell Stock (Java)
- leetcode-121 Best Time to Buy and Sell Stock
- leetcode || 121、Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock - LeetCode 121
- leetcode#121 Best Time to Buy and Sell Stock
- Leetcode 121 Best Time to Buy and Sell Stock
- Leetcode #121 Best Time to Buy and Sell Stock
- leetcode 121: Best Time to Buy and Sell Stock
- hdoj 2035人见人爱A^B 解题报告
- android error opening trace file no such file or directory
- leetcode.52. N-Queens II
- [bzoj4755][JSOI2016]扭动的回文串
- mySql基本语法三
- leetcode 121 Best Time to Buy and Sell Stock C++
- Astar Round2B
- IOS数据存储常用的5种方式
- jquery中html()、text()、val()的区别
- 界面刷新
- Android广播机制
- Activity生命周期和启动模式
- 最长回文子串
- HDU1005 Number Sequence