Does the server have any memory issue?


  • 0
    Q

    The server always reports memory limit exceeded. I comment out all the code and just left the following. It still has the same issue. Is someone else experiencing similar issue?

    int maxProfit(int k, vector<int> &prices) {
        if(prices.size() <= 1 || k == 0) {
            return 0;
        }
        if(k >= prices.size() - 1) {
            k = prices.size() - 1;
        }
        vector<vector<int>> dp;
        for(int i = 0; i < prices.size(); ++i) {
            vector<int> row(k + 1);
            dp.push_back(row);
        }
        return dp.size();
    }

  • 0
    K

    What's the size of prices? It seems that a large vector<int> prices will cause the problem. So even no logic there, a large vector will consume out your memory space.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.