forked from fishercoder1534/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_359.java
34 lines (28 loc) · 870 Bytes
/
_359.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.fishercoder.solutions;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class _359 {
public static class Solution1 {
class Logger {
private Map<String, Integer> map;
public Logger() {
map = new HashMap<>();
}
public boolean shouldPrintMessage(int timestamp, String message) {
if (!map.containsKey(message)) {
map.put(message, timestamp);
return true;
} else {
if (timestamp - map.get(message) < 10) {
return false;
} else {
map.put(message, timestamp);
return true;
}
}
}
}
}
}