买卖股票的最佳时机
class Solution {
public:
/**
* @param prices: Given an integer array
* @return: Maximum profit
*/
int maxProfit(vector<int> &prices) {
// write your code here
int n = prices.size();
int res = 0;
for (int i = 0; i < n-1; i ++)
if (prices[i+1] - prices[i] > 0)
res += prices[i+1] - prices[i];
return res;
}
};