标签:ice pre space name vector price ++ namespace max
class Solution { public: int maxProfit(vector<int> &prices) { using namespace std; int profit=0; if(prices.size()<2) { return profit; } else { int lost=prices[0]; for(int i=1;i<prices.size();i++) { profit=max(profit,prices[i]-lost); lost=min(lost,prices[i]); } } return profit; } };
标签:ice pre space name vector price ++ namespace max
原文地址:http://www.cnblogs.com/ZJJ644758437/p/6517373.html