Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2624c2d

Browse files
refactor 359
1 parent58282d8 commit2624c2d

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,14 @@ public static class Solution1 {
1111
classLogger {
1212

1313
privateMap<String,Integer>map;
14-
privateSet<String>set;
1514

16-
/**
17-
* Initialize your data structure here.
18-
*/
1915
publicLogger() {
20-
map =newHashMap<String,Integer>();
21-
set =newHashSet<String>();
16+
map =newHashMap<>();
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
publicbooleanshouldPrintMessage(inttimestamp,Stringmessage) {
29-
if (!set.contains(message)) {
20+
if (!map.containsKey(message)) {
3021
map.put(message,timestamp);
31-
set.add(message);
3222
returntrue;
3323
}else {
3424
if (timestamp -map.get(message) <10) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp