标签:cpp out sel time solution end ice ++ turn
class Solution { public: int maxProfit(vector<int>& prices) { int local=0,golal = 0; for (int i=0; i<prices.size()-1; i++) { local = max(local + (prices[i+1] - prices[i]), 0); golal = max(golal,local); } cout<<golal<<endl; return golal; } };
leetcode 122 . Best Time to Buy and Sell Stock II
标签:cpp out sel time solution end ice ++ turn
原文地址:http://www.cnblogs.com/sxy-798013203/p/7653564.html