File tree 1 file changed +2
-12
lines changed
src/main/java/com/fishercoder/solutions
1 file changed +2
-12
lines changed Original file line number Diff line number Diff line change @@ -11,24 +11,14 @@ public static class Solution1 {
11
11
class Logger {
12
12
13
13
private Map <String , Integer > map ;
14
- private Set <String > set ;
15
14
16
- /**
17
- * Initialize your data structure here.
18
- */
19
15
public Logger () {
20
- map = new HashMap <String , Integer >();
21
- set = new HashSet <String >();
16
+ map = new HashMap <>();
22
17
}
23
18
24
- /**
25
- * Returns true if the message should be printed in the given timestamp, otherwise returns
26
- * false. The timestamp is in seconds granularity.
27
- */
28
19
public boolean shouldPrintMessage (int timestamp , String message ) {
29
- if (!set . contains (message )) {
20
+ if (!map . containsKey (message )) {
30
21
map .put (message , timestamp );
31
- set .add (message );
32
22
return true ;
33
23
} else {
34
24
if (timestamp - map .get (message ) < 10 ) {
You can’t perform that action at this time.
0 commit comments