```
/*
* greedy: get profit every increase, then you can get the total max profit;
*/
int maxProfit(vector<int> &prices) {
int n = prices.size();
if(n <= 1) return 0;
int profit = 0, dist = 0;
for(int i = 1; i < n; i++){
dist = prices[i] - prices[i-1];
if(dist > 0) profit += dist;
}
return profit;
}
```