Java memorization
If you like the solution please upvote, thanks!\n\nclass Solution {\n    int m, n, c, max;\n    Map<Integer, Boolean> map;\n    ThreadLocalRandom r = ThreadLoca
If you like the solution please upvote, thanks!\n```\nclass Solution {\n    int m, n, c, max;\n    Map<Integer, Boolean> map;\n    ThreadLocalRandom r = ThreadLocalRandom.current();\n    \n    public Solution(int m, int n) {\n        this.m = m;\n        this.n = n;\n        c = m * n;\n        max = c;\n        map = new HashMap<>();\n    }\n    \n    public int[] flip() {\n        if (c == 0)\n            return null;\n        int x;\n        while (true) {\n            x = r.nextInt(0, max);\n            if (map.get(x) == null)\n                break;\n        };\n        map.put(x, true);\n        c--;\n        return new int[]{x / n, x % n};\n    }\n    \n    public void reset() {\n        c = m * n;\n        map = new HashMap<>();\n    }\n}\n```
[]