Java Solution Using HashSet and Random Function
Using Math.random function to select a random number and HashSet to store the cell whose value is already flipped to 1. So, that we don\'t pick it next time.\n\
Using Math.random function to select a random number and HashSet to store the cell whose value is already flipped to 1. So, that we don\'t pick it next time.\n\n```\nclass Solution {\n    private int m;\n    private int n;\n    private HashSet<String> mat;\n\n    public Solution(int m, int n) {\n        mat = new HashSet<>();\n        this.m = m;\n        this.n = n;\n    }\n    \n    public int[] flip() {\n        int r = (int) (Math.random() * m);\n        int c = (int) (Math.random() * n);\n        \n        while(mat.contains(r + " " + c)){\n            r = (int) (Math.random() * m);\n            c = (int) (Math.random() * n);\n        }\n            \n        int output[] = {r, c};\n        mat.add(r + " " + c);\n                               \n        return output;\n    }\n    \n    public void reset() {\n        mat.clear();\n    }\n}\n\n/**\n * Your Solution object will be instantiated and called as such:\n * Solution obj = new Solution(m, n);\n * int[] param_1 = obj.flip();\n * obj.reset();\n */\n```\n\nAny suggestions to improve the code are welcomed.
['Java']