public Log(int time, String message) {
private Deque<Log> deque;
/** Initialize your data structure here. */
deque = new ArrayDeque();
/** 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. */
public boolean shouldPrintMessage(int timestamp, String message) {
while (!deque.isEmpty() && (deque.peek().time <= timestamp - 10)) {
Log oldLog = deque.remove();
set.remove(oldLog.message);
if (!set.contains(message)) {
deque.add(new Log(timestamp, message));
* Your Logger object will be instantiated and called as such:
* Logger obj = new Logger();
* boolean param_1 = obj.shouldPrintMessage(timestamp,message);