Maximum Gap
If  number n appears at positions i and j, it will take (j - i) / 2 seconds to make all numbers between i and j equal n.\n\nSo, we need to find the maximum gap 
If  number `n` appears at positions `i` and `j`, it will take `(j - i) / 2` seconds to make all numbers between `i` and `j` equal `n`.\n\nSo, we need to find the maximum gap for all positions of `n`.\n\n## Collect Positions\nFor each number, we store its positions in a hash map of vectors.\n\nThen, for each `n`, we compute a maximum gap between two consecutive positions. \n\n> Note that we add one more position - `pos[0] + nums.size()` - to simulate a gap between the first and last positions.\n\nIn the end, we return the smallest maximum gap among all numbers.\n\n**C++**\n```cpp\nint minimumSeconds(vector<int>& nums) {\n    unordered_map<int, vector<int>> n_pos;\n    for (int i = 0; i < nums.size(); ++i)\n        n_pos[nums[i]].push_back(i);\n    int res = INT_MAX;\n    for (auto &[n, pos] : n_pos) {\n        pos.push_back(pos[0] + nums.size());\n        int seconds = 0;\n        for (int i = 1; i < pos.size(); ++i)\n            seconds = max(seconds, (pos[i] - pos[i - 1]) / 2);\n        res = min(res, seconds);\n    }\n    return res;\n}\n```\n\n## One Pass\nSimilar to above, but using two maps to track the most recent `pos` and the largest `gap` for each number.\n\nNote that here `i` goes to `nums.size() * 2` to simulate a circular array.\n\n**Python 3**\n```python\nclass Solution:\n    def minimumSeconds(self, nums: List[int]) -> int:\n        pos, gap = {}, defaultdict(lambda: 0)\n        for i, n in enumerate(nums + nums):\n            if n in pos:\n                gap[n] = max(gap[n], (i - pos[n]) // 2)\n            pos[n] = i\n        return min(gap.values())\n```\n\n**C++**\n```cpp\nint minimumSeconds(vector<int>& nums) {\n    unordered_map<int, int> pos, gap;\n    for (int i = 0; i < nums.size() * 2; ++i) {\n        int n = nums[i % nums.size()];\n        if (pos.count(n))\n            gap[n] = max(gap[n], (i - pos[n]) / 2);\n        pos[n] = i;\n    }\n    return min_element(begin(gap), end(gap), [](const auto &p1, const auto &p2){\n        return p1.second < p2.second;\n    })->second;\n}\n```
['C']