class Solution { public: /** * * @param prices int整型vector * @return int整型 */ int maxProfit(vector<int>& prices) { // write code here int profit = 0; int size = prices.size(); for(int i=1; i<size; ++i){ if(prices[i] >= prices[i-1]){ profit += prices[i] - prices[i-1]; } } return profit; } };