int maxProfit(int* prices, int pricesSize) { int retProfit = ; for (int i = ; i < pricesSize - ; i++) { if (prices[i] > prices[i + ]) { continue; } else { retProfit += prices[i + ] - prices[i]; } } return retProfit; }思路:算法可以直接简化为只要今天比昨天大,就卖出。