leetcode 122 Best Time to Buy and Sell Stock II

来源:互联网 发布:淘宝开店审核要多久 编辑:程序博客网 时间:2024/06/04 18:52
public class Solution {    public int maxProfit(int[] prices) {        int total = 0;        for (int i = 0; i < prices.length-1; i++)            if (prices[i+1] > prices[i])                total += prices[i+1] - prices[i];        return total;    }}

0 0
原创粉丝点击