Solution Random Flip Matrix
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    private $rows;\n    private $cols;\n    private $total;\n    private $flipped;\n    \n    /**\n     * @param Integer $m\n     * @param Integer $n\n     */\n    function __construct($m, $n) {\n        $this->rows = $m;\n        $this->cols = $n;\n        $this->total = $m * $n;\n        $this->flipped = [];\n    }\n  \n    /**\n     * @return Integer[]\n     */\n    function flip() {\n        $randIndex = rand(0, --$this->total);\n        $index = $this->flipped[$randIndex] ?? $randIndex;\n        $this->flipped[$randIndex] = $this->flipped[$this->total] ?? $this->total;\n        unset($this->flipped[$this->total]);\n        \n        return [intval($index / $this->cols), $index % $this->cols];\n    }\n  \n    /**\n     * @return NULL\n     */\n    function reset() {\n        $this->total = $this->rows * $this->cols;\n        $this->flipped = [];\n    }\n}\n\n```
['PHP']