122. Best Time to Buy and Sell Stock II**
来源:互联网 发布:2017人工智能最新进展 编辑:程序博客网 时间:2024/06/05 05:30
Say you have an array for which the ith element is the price of a given stock on day i.
Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times). However, you may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).
Reference
class Solution(object): def maxProfit(self, prices): """ :type prices: List[int] :rtype: int """ result = 0 n = len(prices) for i in range(n-1): if prices[i+1]>prices[i]: result +=prices[i+1]-prices[i] return result
0 0
- 122. Best Time to Buy and Sell Stock II
- LeetCode 122. Best Time to Buy and Sell Stock II
- 122.Best Time to Buy and Sell Stock II
- [Leetcode] 122. Best Time to Buy and Sell Stock II
- [leetcode] 122.Best Time to Buy and Sell Stock II
- 【leetcode】122.Best Time to Buy and Sell Stock II
- 122. Best Time to Buy and Sell Stock II
- 【LeetCode】122.Best Time to Buy and Sell Stock II
- [leetcode] 122. Best Time to Buy and Sell Stock II
- LeetCode #122. Best Time to Buy and Sell Stock II
- 122. Best Time to Buy and Sell Stock II LeetCode
- 122. Best Time to Buy and Sell Stock II
- 122. Best Time to Buy and Sell Stock II
- 122. Best Time to Buy and Sell Stock II
- [LeetCode]122. Best Time to Buy and Sell Stock II
- 122. Best Time to Buy and Sell Stock II
- Leetcode 122. Best Time to Buy and Sell Stock II
- leetcode 122. Best Time to Buy and Sell Stock II
- linux下sftp
- HLS协议深入分析——时间线介绍(二)
- servlet路径访问问题
- Android 6.0 新功能及主要 API 变更
- class和ID的区别
- 122. Best Time to Buy and Sell Stock II**
- 使用Vitamio打造自己的Android万能播放器(1)——准备
- 反射:运行时的类信息
- 51NOD 1672 区间交 线段树
- MATLAB 编程风格指南
- Android完全退出程序、线程
- ViewPager无限轮播+轮播时下面的小点跟着走
- 【bzoj1502】 NOI2005—月下柠檬树
- 状态模式——你若安好,便是晴天