clueless coding // TODO: be smarter

LeetCode Logger Rate Limiter: CPP Solution

TL;DR Code Solution

unordered_map<string, int> map;
/** Initialize your data structure here. */
Logger() {


/** Returns true if the message should be printed in the given timestamp, otherwise returns false.
    If this method returns false, the message will not be printed.
    The timestamp is in seconds granularity. */
bool shouldPrintMessage(int timestamp, string message) {
    if (map.find(message) == map.end() || map[message] + 10 <= timestamp) {
        map[message] = timestamp;
        return true;
    return false;