simple C++ solution using the least amount of randomness
This solution will only need to sample 1 random number from a uniform_int_distribution for each call to the flip() method. So, it\'s about as optimized as can b
This solution will only need to sample 1 random number from a uniform_int_distribution for each call to the flip() method. So, it\'s about as optimized as can be in term of using the least amount of randomness from the operating system\'s entropy pool.\n\n```\nclass Solution {\npublic:\n    Solution(int n_rows, int n_cols) : nrows_(n_rows), ncols_(n_cols) {\n        auto const num_zeroes = nrows_ * ncols_;\n        zeroes_.reserve(num_zeroes);\n        for (int i = 0; i < num_zeroes; ++i)\n            zeroes_.emplace_back(i);\n        reset();\n    }\n    \n    vector<int> flip() {\n        auto const idx = uniform_int_distribution<int>(0, --numRemaining_)(generator_);\n        swap(zeroes_[idx], zeroes_[numRemaining_]);\n        auto const res = zeroes_[numRemaining_];\n        return {res / ncols_, res % ncols_};\n    }\n    \n    void reset() {\n        numRemaining_ = nrows_ * ncols_;\n    }\n    \nprivate:\n    int const nrows_;\n    int const ncols_;\n    int numRemaining_;\n    vector<int> zeroes_;\n    // the random number generator\n    mt19937 generator_;\n};\n```
[]