Java : 97% speed and 66.67% memory : using Szudzik's Pairing Function and HashSet
\nclass Solution {\n    \n    private int M, N;\n    private HashSet<Integer> set;\n    private Random r;\n    public Solution(int n_rows, int n_cols) {\n      
```\nclass Solution {\n    \n    private int M, N;\n    private HashSet<Integer> set;\n    private Random r;\n    public Solution(int n_rows, int n_cols) {\n        M = n_rows;\n        N = n_cols;\n        r = new Random();\n        set = new HashSet<Integer>();\n    }\n    private int hashCode(int x, int y){\n        // Szudzik\'s Pairing Function - guaranteed to be unique\n        if(x < y){\n           return x + y*y;\n        }else{\n           return x*x + x + y;\n        }\n    }\n    \n    public int[] flip() {\n        int row, col;\n        while(true){\n            row = r.nextInt(M);\n            col = r.nextInt(N);\n            if(set.add(hashCode(row, col)))\n                return new int[]{row, col};\n        }\n    }\n    \n    public void reset() {\n        set.clear();\n    }\n}\n\n/**\n * Your Solution object will be instantiated and called as such:\n * Solution obj = new Solution(n_rows, n_cols);\n * int[] param_1 = obj.flip();\n * obj.reset();\n */\n```
[]