class Solution { public int maxProfit(int[] prices) { int sum = 0; for (int i = 1;i < prices.length; ++ i) { if (prices[i] > prices[i - 1]) { sum += prices[i] - prices[i - 1]; } } return sum; } }
LeetCode - 122. 买卖股票的最佳时机 II
猜你喜欢
转载自blog.51cto.com/tianyiya/2174495
今日推荐
周排行