clueless coding // TODO: be smarter

LeetCode Logger Rate Limiter: Java Solution



TL;DR Code Solution


ss Logger {

    /** Initialize your data structure here. */
    private Map<String, Integer> ok = new HashMap<>();

    public boolean shouldPrintMessage(int timestamp, String message) {
        if (timestamp < ok.getOrDefault(message, 0))
            return false;
        ok.put(message, timestamp + 10);
        return true;
    }