1class Solution {2 public int maxProfit(int[] prices) {3 int n = prices.length, profit = 0;4 for (int i = 0; i < n - 1; i++) {5 if (prices[i + 1] > prices[i]) {6 profit += prices[i + 1] - prices[i];7 }8 }9 return profit;10 }11}
WPM •0 •0
ACC •0 •0
TIME •0