C++ Simple Solution
int maxProfit(vector<int>& prices) {\n        int ret = 0, max = 0;\n        for(int i = 1; i < prices.size(); i++)\n        {\n            ret += prices[i] - p
    int maxProfit(vector<int>& prices) {\n        int ret = 0, max = 0;\n        for(int i = 1; i < prices.size(); i++)\n        {\n            ret += prices[i] - prices[i-1];\n            if(ret < 0) ret = 0;\n            if(ret > max) max = ret;\n         }\n         return max;\n    }
['C++']