Find min of max gap
Intuition\n- A little counter intuitive: most frequent element is NOT necessarily the final equalizer. For example, 3 \'20\' clusters together, vs, 2 \'10\' cut
# Intuition\n- A little counter intuitive: `most frequent element` is NOT necessarily the final equalizer. For example, 3 \'20\' clusters together, vs, 2 \'10\' cuts array in equal 3 parts, the latter will be better equalizer (taking less operations to reach)\n- Brute force to try each element as equalizer candidate by tracking its occurrence positions/indices and find the `max index/position gap`.\n\n# Approach\n- `unordered_map` to track positions/indices\n- `adjacent_difference` to calcualte gaps\n- `max_element` to find the cost for candidate equalizer\n\n# Complexity\n- Time complexity:\n`O(N)`\n\n- Space complexity:\n`O(N)`\n# Code\n```\nclass Solution {\npublic:\n    int minimumSeconds(vector<int>& nums) {\n        unordered_map<int, vector<int>> indices;\n        int sz = nums.size();\n        for(int i = 0; i < sz; ++i) {\n            indices[nums[i]].push_back(i);\n        }\n        int ans = INT_MAX;\n        for(auto & [_, idxs] : indices) {\n            idxs.push_back(idxs.front() + sz);\n            adjacent_difference(idxs.begin(), idxs.end(), idxs.begin());\n            ans = min(ans, *max_element(idxs.begin()+1, idxs.end()) / 2);\n        }\n        return ans;\n    }\n};\n```
['C++']