✅ Javascript | Simplest Solution | 🏆Hash Set🏆 |🔥Beats 100%🔥
\n\n# Intuition\nGenerate indices (0, m) and (0, n) and use Hash Set to store already generated indices.\n\n# Approach\nDefine m (number of rows), n (number of 
![image.png](https://assets.leetcode.com/users/images/852e52f4-b3de-4c90-b1b3-08516e04d41e_1717520098.3015432.png)\n\n# Intuition\nGenerate indices `(0, m)` and `(0, n)` and use Hash Set to store already generated indices.\n\n# Approach\nDefine `m` (number of rows), `n` (number of columns) and `set` to store already generated indices.\n\nIn `flip` method run `generator` and generate until generate indices not presented in `set`, then add `key` to `set` and return `value`.\n\nIn `reset` method clear `set`.\n\nIn `generate` method generate `m` from `0` to `this.m - 1`, `n` from `0` to `this.n - 1` and forming as `[m, n]`. Return object with stringifyed and original version.\n\n\n# Complexity\n- Time complexity:\n$$O(k)$$\n\n- Space complexity:\n$$O(k)$$\n\n# Code\n```\n/**\n * @param {number} m\n * @param {number} n\n */\nvar Solution = function(m, n) {\n    this.m = m;\n    this.n = n;\n    this.set = new Set();\n};\n\n/**\n * @return {number[]}\n */\nSolution.prototype.flip = function() {\n    let generated = this.generate();\n\n    while(this.set.has(generated.key)) {\n        generated = this.generate();\n    }\n\n    this.set.add(generated.key);\n\n    return generated.value;\n};\n\n/**\n * @return {void}\n */\nSolution.prototype.reset = function() {\n    this.set.clear();\n};\n\n/**\n * @return {void}\n */\nSolution.prototype.generate = function() {\n    const m = Math.ceil(Math.random() * this.m - 1);\n    const n = Math.ceil(Math.random() * this.n - 1);\n\n    const value = [m, n];\n\n    return {key: `${value}`, value};\n};\n\n/** \n * Your Solution object will be instantiated and called as such:\n * var obj = new Solution(m, n)\n * var param_1 = obj.flip()\n * obj.reset()\n */\n```
['Hash Table', 'JavaScript']