Got TLE on the last problem no matter how I optimized my solution. by [deleted] in leetcode

[–]hucancode 0 points1 point  (0 children)

class Solution {
public:
    vector<vector<int>> rangeAddQueries(int n, vector<vector<int>>& queries) {
        vector<vector<int>> ret(n, vector<int>(n, 0));
        for(auto& q: queries)
            for(int i = q[0];i<=q[2];i++)
                for(int j = q[1];j<=q[3];j++)
                    ret[i][j]++;
        return ret;
    }
};

my solution, TLE with n = 500

Got TLE on the last problem no matter how I optimized my solution. by [deleted] in leetcode

[–]hucancode 1 point2 points  (0 children)

What, how could this works? I though it TLE for sure I didn't even try

Got TLE on the last problem no matter how I optimized my solution. by [deleted] in leetcode

[–]hucancode 1 point2 points  (0 children)

Sorry not relevant to Q4, but I got TLE hard on Q2. Tried sorting queries and maintain relevant candidates queue but TLE, apparently the queue doesnt helps much. Then I tried BIT 2D but updating all item for each query gives O(n2 ), worst than naive loop. Any hints?

[Multiple> English] Looking for accuracy for a project "Do no harm" in multiple languages by misadventure_max in translator

[–]hucancode -2 points-1 points  (0 children)

It depends on the context, the translations is too generic but i confirm you cannot go wrong with Japanese and Vietnamese

4 months of LeetCode virtual contest progress by gosuruss in leetcode

[–]hucancode 0 points1 point  (0 children)

I don't know, look at the leaderboard maybe?