My own answer, not good

class Solution {
public:
    int maxProfit(vector<int> &prices) {
        // IMPORTANT: Please reset any member data you declared, as
        // the same Solution instance will be reused for each test case.
        if (prices.size()<2) return 0;
        vector <int> day_profit;
        for(int i=0; i<prices.size()-1; i++)
        {
            day_profit.push_back(prices[i+1]-prices[i]);
        }
        int high_profit = 0;
        int temp = 0;
        for(int i=1; i<=day_profit.size(); i++)
        {
            int j=0;
            while(j+i<=day_profit.size())
            {
                temp = 0;
                for(int k = j; k<j+i; k++)
                {
                    temp += day_profit[k];
                }
                if (high_profit<temp) high_profit = temp;
                j++;
            }
        }
        return high_profit;
    }
};