class Logger {
private:
unordered_map<string, int> msgToTime;
public:
Logger() {
}
bool shouldPrintMessage(int timestamp, string message) {
if (!msgToTime.count(message)) {
msgToTime[message] = timestamp;
return true;
}
if (timestamp - msgToTime[message] >= 10) {
msgToTime[message] = timestamp;
return true;
} else {
return false;
}
}
};
/**
* Your Logger object will be instantiated and called as such:
* Logger* obj = new Logger();
* bool param_1 = obj->shouldPrintMessage(timestamp,message);
*/