Skip to content

Commit 2624c2d

Browse files
refactor 359
1 parent 58282d8 commit 2624c2d

File tree

1 file changed

+2
-12
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+2
-12
lines changed

src/main/java/com/fishercoder/solutions/_359.java

+2-12
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,14 @@ public static class Solution1 {
1111
class Logger {
1212

1313
private Map<String, Integer> map;
14-
private Set<String> set;
1514

16-
/**
17-
* Initialize your data structure here.
18-
*/
1915
public Logger() {
20-
map = new HashMap<String, Integer>();
21-
set = new HashSet<String>();
16+
map = new HashMap<>();
2217
}
2318

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-
*/
2819
public boolean shouldPrintMessage(int timestamp, String message) {
29-
if (!set.contains(message)) {
20+
if (!map.containsKey(message)) {
3021
map.put(message, timestamp);
31-
set.add(message);
3222
return true;
3323
} else {
3424
if (timestamp - map.get(message) < 10) {

0 commit comments

Comments
 (0)