122 Best Time to Buy and Sell Stock II
来源:互联网 发布:汉朗网络信息科技 编辑:程序博客网 时间:2024/06/01 09:49
与一非常类似。只需要改一个条件。
public class Solution { public int maxProfit(int[] prices) { if (prices == null || prices.length <= 1) { return 0; } int max = Integer.MIN_VALUE; int sum = 0; for (int i = 1; i < prices.length; i++) { int localprofit = prices[i] - prices[i - 1]; if (localprofit > 0) { sum+=localprofit; } max = Math.max(max, sum); } return max; }}
0 0
- 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
- LeetCode: Best Time to Buy and Sell Stock II [122]
- [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
- 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
- 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
- 122 Best Time to Buy and Sell Stock II
- LeetCode 122 Best Time to Buy and Sell Stock II
- Kconfig和Makefile,在Linux目录中增加目录
- iOS应用架构谈 view层的组织和调用方案
- Leetcode Multiply Strings
- iOS 关于NSArray中的调用方法
- spring框架学习(四)自动装配
- 122 Best Time to Buy and Sell Stock II
- 1009. 说反话 (20)
- 清除缓存
- Activity的生命周期(转载)
- spring框架学习(五)注解
- 计算机中通信的思考
- 是什么原因导致 无法连接到远程服务器
- CSP和PKCS#11的关系
- 遗传算法入门到掌握(二)