力扣122. 买卖股票的最佳时机 II
class Solution {
public:
int a[100000];
int maxProfit(vector<int>& prices) {
for(int i=0;i<prices.size();i++){a[i]=prices[i];}
a[prices.size()]=-1;
int ans=0,Min=100000;
for(int i=0;i<=prices.size();i++){
if(Min>a[i]){Min=a[i];}
if(a[i]>a[i+1]&&a[i]-Min>0){
ans+=a[i]-Min;
Min=10000;
}
printf("%d ",Min);
}
return ans;
}
};