Short C++ code - beats 100%


  • 0
    G
        unordered_map<string, int> mp;
        Logger() {}
        bool shouldPrintMessage(int timestamp, string message) {
            unordered_map<string, int>::iterator it = mp.find(message);
            if (it != mp.end() && timestamp - it->second < 10) return false;
            mp[message] = timestamp;
            return true;
        }
    

Log in to reply
 

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