贪心难度简单题目描述解题思路Code 贪心 难度简单 题目描述 解题思路贪心思想,只要明天比今天股价高,那么今天买入明天卖出 Codepublic int maxProfit(int[] prices) { int profit = 0; for (int i = 0; i < prices.length - 1; i++) { if (prices[i + 1] > prices[i]) { profit += prices[i + 1] - prices[i]; } } return profit;}