- Leetcode PHP题解--D109 122. Best T
- leetcode:122. Best Time to Buy a
- [数组]122. Best Time to Buy and Se
- Leetcode122-Best Time to Buy and
- 跟我一起刷leetCode算法题9之Best Time to B
- 121. Best Time to Buy and Sell S
- 【2019-07-30】leetcode(121-130)
- 121. Best Time to Buy and Sell S
- BestTimeToBuyAndSellStock with c
- [2018-11-18] [LeetCode-Week11] 1
public class Solution {
public int maxProfit(int[] prices) {
if(prices.length==0) return 0;
int max=0;
for(int i=0;i<prices.length-1;i++){
if(prices[i+1]>prices[i]) max+=prices[i+1]-prices[i];
}
return max;
}
}
网友评论