Super Simple Java Solution using Set with explanation
The solution is simple as follows;\n1- Multiply rows with columns. Then i is randomNumber/Columns and j is randomNumber%Columns\n2- Insert each random number in
The solution is simple as follows;\n1- Multiply rows with columns. Then i is randomNumber/Columns and j is randomNumber%Columns\n2- Insert each random number into the Set. If it exists in the set retry till get the a random number which does not exists in the set\n3- For reset, just reset the set\n```\n\t Set<Integer> set; int randomNo=0; int js=0;\n\t Random random;\n\t    public Solution(int n_rows, int n_cols) {\n\t    \tjs=n_cols; randomNo=n_rows*n_cols;\n\t    \tset=new HashSet<>();\n\t    \trandom=new Random();\n\t    }\t    \n\t    public int[] flip() {\n\t        int next = random.nextInt(randomNo);            \n\t        while(!set.add(next)) next = random.nextInt(randomNo);  //retry till does not exist in the set\n\t        return new int[]{next/js, next%js}; //i=next/js  & j=next%js\n\t    }\t    \n\t    public void reset() {\n\t    \tset.clear(); //clear the set\n\t    }\n```
[]