Best Time to Buy and Sell Stock II
来源:互联网 发布:我国历年gdp数据 编辑:程序博客网 时间:2024/05/18 00:02
题目链接
思想:
贪心算法。只要第二天的价格比当天高,那么就买入然后第二天卖掉。
int profit=0; for(int i=0;i<prices.length-1;i++) { if(prices[i]<prices[i+1]) { profit+=prices[i+1]-prices[i]; } } return profit;
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
- 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
- Best Time to Buy and Sell Stock II
- 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
- Best Time to Buy and Sell Stock II
- 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
- JNDI配置c3p0连接池
- hdu-3008魔兽争霸
- [译]Front-end-Developer-Interview-Questions
- 《Objective-C基础教程》第四章 继承
- poj1753 Flip Game DFS,枚举
- Best Time to Buy and Sell Stock II
- [Learning Linux For Fun] unit 1 1.2~1.3
- leetcode_Median of Two Sorted Arrays
- LeetCode(116) Populating Next Right Pointers in Each Node
- 智慧城市
- UE4 移动平台游戏开发
- iOS 9之分屏多任务(Split View)
- POJ 1511 SPFA 模板
- C++对象模型——对象成员的效率 (Object Member Efficiency)(第三章)