Random Flip Matrix: easy O(1) solution. ✅
IntuitionThe first thought is to use an efficient way to track which cells have been flipped and ensure that each cell is flipped exactly once. The approach mus
# Intuition
The first thought is to use an efficient way to track which cells have been flipped and ensure that each cell is flipped exactly once. The approach must handle the constraints of preventing any cell from being flipped more than once without excessive time complexity.

# Approach
Initialization: Initialize a dictionary to map the index of the cells and an integer to keep track of the total number of cells.

Flip Function: Implement a method to flip a cell. Generate a random index and check if it has already been flipped. If not, mark it as flipped and map it to another index if necessary to avoid future duplications. Decrement the total count of available cells.

Reset Function: Reset the grid to its initial state by clearing the dictionary and resetting the total count of cells.

# Complexity
- Time complexity:
O(1)

- Space complexity:
O(m*n)

# Code
```python3 []
class Solution:

    def __init__(self, m: int, n: int):
        self.m = m
        self.n = n
        self.total = m * n
        self.reset()

    def flip(self) -> List[int]:
        rand_index = random.randint(0, self.total - 1)
        # Trova la posizione dell'indice casuale
        x = self.map.get(rand_index, rand_index)
        # Sostituisce l'indice con l'ultimo non usato
        self.map[rand_index] = self.map.get(self.total - 1, self.total - 1)
        self.total -= 1
        return [x // self.n, x % self.n]

    def reset(self) -> None:
        self.total = self.m * self.n
        self.map = {}

```
['Hash Table', 'Randomized', 'Python3']