Algorithms—122.Best Time to Buy and Sell Stock II
来源:互联网 发布:简历管理系统 源码 编辑:程序博客网 时间:2024/06/05 15:10
思路:比121题更简单,不限制交易次数。
public class Solution { public int maxProfit(int[] prices) {if (prices.length <= 1) {return 0;}int[] change = new int[prices.length - 1];for (int i = 0; i < change.length; i++) {change[i] = prices[i + 1] - prices[i];}int sum = 0;for (int i = 0; i < change.length; i++) {if (change[i]>0) {sum+=change[i];}}return sum;}}
0 0
- Algorithms—122.Best Time to Buy and Sell Stock II
- Algorithms—121.Best Time to Buy and Sell Stock
- 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
- 从K近邻算法、距离度量谈到KD树、SIFT+BBF算法
- windows7系统 Internet 信息服务(IIS)管理器 默认网站 右键 没有属性这一项怎么办?
- 集训队分组
- Algorithms—121.Best Time to Buy and Sell Stock
- Android中常见管理者对象的获取
- Algorithms—122.Best Time to Buy and Sell Stock II
- 小插曲:excel的表间数据引用公式vlookup
- 'adb' 不是内部或外部命令,也不是可运行的程序或批处理文件。
- 半夜撸 flap bird
- Leetcode 之 Find Minimum in Rotated Sorted Array
- codeforces 549D D. Haar Features(枚举)
- 【leetcode c++】27 Remove Element
- ubuntu中vi不能正常使用方向键与退格键的问题
- OpenLayers学习笔记10——datagrid双击缩放指定点