你可以無限次買賣股票(只要你先買了才能賣),求能夠獲得的最大總利潤
class Solution {
public:
int maxProfit(vector<int>& prices) {
int profit = 0;
for (int i = 1; i < prices.size(); i++){
int temp = prices[i] - prices[i - 1];
if (temp > 0) profit += temp;
}
return profit;
}
};