C++ What's all the fuss about memory limit? It seems like just storing string works.


  • 0
    W
    vector<string> findRepeatedDnaSequences(string s) 
    {
        unordered_set<string> memo;
        unordered_set<string> result;
        for (int i = 9; i < s.size(); i++)
        {
            string str = s.substr(i-9, 10);
            if (memo.count(str) == 0)
                memo.insert(str);
            else
                result.insert(str);
        }
        
        return vector<string>(result.begin(), result.end());
    }

  • 0

    How did you miss the comment in those questions saying that the memory limit got removed three days ago, thanks to those complaints?


  • 0
    W

    Oh I only read the questions and replies not comments. Those one I read didn't say that. Now it makes sense. Thanks!


Log in to reply
 

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