LeetCode之Best Time to Buy and Sell Stock II
来源:互联网 发布:网络共享文件夹打不开 编辑:程序博客网 时间:2024/06/02 10:19
/*可以多次交易,但是只能同时持有一个股。则对于当天的股,只要在第二天卖出能够盈利,那么就买进,第二天卖出。*/class Solution {public: int maxProfit(vector<int>& prices) { if(prices.size() <= 1) return 0; int res(0); for(int i = 1; i < prices.size(); ++i){ if(prices[i] > prices[i-1]) res += prices[i] - prices[i-1]; } return res; }};
0 0
- LeetCode之Best Time to Buy and Sell Stock II
- LeetCode 之 Best Time to Buy and Sell Stock II
- LeetCode之Best Time to Buy and Sell Stock II
- leetcode之Best Time to Buy and Sell Stock II
- LeetCode之Best Time to Buy and Sell Stock II
- LeetCode 之 Best Time to Buy and Sell Stock II
- leetcode之Best Time to Buy and Sell Stock II
- LeetCode之Best Time to Buy and Sell Stock II
- [LeetCode]Best Time to Buy and Sell Stock II
- LeetCode Best Time to Buy and Sell Stock II
- Leetcode: Best Time to Buy and Sell Stock II
- [Leetcode] Best Time to Buy and Sell Stock II
- LeetCode : Best Time to Buy and Sell Stock II
- LeetCode Best Time to Buy and Sell Stock II
- [LeetCode] Best Time to Buy and Sell Stock II
- leetcode 61: Best Time to Buy and Sell Stock II
- [LeetCode] Best time to buy and sell a stock II
- 【leetcode】Best Time to Buy and Sell Stock II
- IOS--Swift 01
- sql存储过程
- Handler 机制学习之基本用法
- 为html表格添加双击事件,并获取<td>节点的值
- java中Map,List与Set的区别(一)
- LeetCode之Best Time to Buy and Sell Stock II
- sql实现从两个表获取字段组成表数据再插入到函数表中
- x5studio的常用操作
- Git简单介绍(一)
- 科研日报 20150831 FFT ETHERNET
- leetcode 238: Product of Array Except Self
- 【JS】测试:HTML页面引入另一个HTML页面,同名ID会冲突吗
- poj 1442.Black Box
- iOS --- 使用GPUImage实现的简单滤镜效果