Open rocksc30 opened 1 year ago
class Solution { public int maxProfit(int[] prices) { int ans = 0; for (int i = 1; i < prices.length; i++){ ans += Math.max(prices[i] - prices[i - 1], 0); } return ans; } }