添加链接描述 贪心 局部最优:手机每天的正利润 全局最优:求最大利润 class Solution { public int maxProfit(int[] prices) { int res = 0; for(int i = 1; i < prices.length; i++){ res += Math.max(prices[i] - prices[i - 1], 0); } return res; } }