nikunjsoni

359

Jun 22nd, 2021
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. class Logger {
  2. private:
  3.     unordered_map<string, int> ok;
  4. public:
  5.     /** Initialize your data structure here. */
  6.     Logger() {
  7.        
  8.     }
  9.    
  10.     /** Returns true if the message should be printed in the given timestamp, otherwise returns false.
  11.         If this method returns false, the message will not be printed.
  12.         The timestamp is in seconds granularity. */
  13.     bool shouldPrintMessage(int timestamp, string message) {
  14.         if(timestamp < ok[message])
  15.             return false;
  16.         ok[message] = timestamp + 10;
  17.         return true;
  18.     }
  19. };
  20.  
  21. /**
  22.  * Your Logger object will be instantiated and called as such:
  23.  * Logger* obj = new Logger();
  24.  * bool param_1 = obj->shouldPrintMessage(timestamp,message);
  25.  */
Advertisement
Add Comment
Please, Sign In to add comment