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;
            private Set<String> set;

            /**
             * Initialize your data structure here.
             */
            public Logger() {
                map = new HashMap<String, Integer>();
                set = new HashSet<String>();
            }

            /**
             * Returns true if the message should be printed in the given timestamp, otherwise returns
             * false. The timestamp is in seconds granularity.
             */
            public boolean shouldPrintMessage(int timestamp, String message) {
                if (!set.contains(message)) {
                    map.put(message, timestamp);
                    set.add(message);
                    return true;
                } else {
                    if (timestamp - map.get(message) < 10) {
                        return false;
                    } else {
                        map.put(message, timestamp);
                        return true;
                    }
                }
            }
        }
    }
}

@@ -257,471 +257,92 @@
 ap;%0A
-            private Set%3CString%3E set;%0A%0A            /**%0A             * Initialize your data structure here.%0A             */%0A            public Logger() %7B%0A                map = new HashMap%3CString, Integer%3E();%0A                set = new HashSet%3CString%3E();%0A            %7D%0A%0A            /**%0A             * Returns true if the message should be printed in the given timestamp, otherwise returns%0A             * false. The timestamp is in seconds granularity.%0A             */
+%0A            public Logger() %7B%0A                map = new HashMap%3C%3E();%0A            %7D%0A
 %0A   
@@ -438,19 +438,19 @@
    if (!
-set
+map
 .contain
@@ -450,16 +450,19 @@
 contains
+Key
 (message
@@ -519,46 +519,8 @@
 p);%0A
-                    set.add(message);%0A
     

refactor 359