122. Best Time to Buy and Sell Stock II - cocoder39/coco39_LC GitHub Wiki
122. Best Time to Buy and Sell Stock II
unlimited transactions is allowed, thus buy can sell whenever you can make profit, just as greedy as possible
int maxProfit(vector<int>& prices) {
int profit = 0;
for(int i = 1; i < prices.size(); i++){
if(prices[i] > prices[i - 1]){ // increase
profit += prices[i] - prices[i - 1];
}
}
return profit;
}