swapping and decreasing length without removing from vector || simple approach
here reset works fine because after few flips array got shuffled but it will not affect the randomness\nso instead of redefining the vector again i have just re
here reset works fine because after few flips array got shuffled but it will not affect the randomness\nso instead of redefining the vector again i have just reset the total length\nhope you like it :)\n_________________________________________________________________\n\nclass Solution {\npublic:\n\n    vector<int> res;\n    int row, col;\n    int total;\n    Solution(int m, int n) {\n        row = m, col = n, total = m*n;\n        res.resize(m*n);\n        iota(res.begin(), res.end(), 0);\n    }\n    \n    vector<int> flip() {\n        int i = rand() % total; total--;\n        int x = res[i];\n        swap(res[i], res[total]);\n        return {x/col, x%col};\n    }\n    \n    void reset() {\n        total = row * col;\n    }\n};\n
[]