class Solution {
public:
int maxDiff(vector<int>& nums) {
if(nums.size()==0) return 0;
int buy=nums[0],res=0;
for (int i = 1; i < nums.size(); i ++ )
{
res=max(res,nums[i]-buy);
buy=min(buy,nums[i]);
}
return res;
}
};
标签:buy,return,最大,nums,int,股票,res,size,利润
From: https://www.cnblogs.com/tangxibomb/p/17397304.html