Python solution with randomized data generation in flip
Question states that number of flip operation can be up to 1000, So, I think this solution won\'t be that bad compared to other approaches because the size of t
Question states that number of flip operation can be up to 1000, So, I think this solution won\'t be that bad compared to other approaches because the size of the matrix can go up to 10^4 * 10^4. And storing all the indices whose values are 0 is imo not that optimal. We can also solve this problem by using reservoir sampling and time complexity will be O(nm) for each flip and there will be the calls to random function can go up to O(nm). \n\n\n```\nclass Solution:\n\n    def __init__(self, m: int, n: int):\n        self.rows = m\n        self.cols = n\n        self.flipped = set()\n\n    def flip(self) -> List[int]:\n        while True:\n            i = random.randrange(self.rows)\n            j = random.randrange(self.cols)\n            if (i, j) not in self.flipped:\n                self.flipped.add((i, j))\n                return (i, j)\n\n    def reset(self) -> None:\n        self.flipped = set()\n\n\n# Your Solution object will be instantiated and called as such:\n# obj = Solution(m, n)\n# param_1 = obj.flip()\n# obj.reset()\n```
['Python']