map O(n)
Intuition\nFind half of gaps between index of same elements\n# Approach\nmap\n# Complexity\n- Time complexity:\nO(n)\n- Space complexity:\n\n# Code\n\nclass Sol
# Intuition\nFind half of gaps between index of same elements\n# Approach\nmap\n# Complexity\n- Time complexity:\nO(n)\n- Space complexity:\n\n# Code\n```\nclass Solution {\npublic:\n    int minimumSeconds(vector<int>& nums) {\n        unordered_map<int, vector<int>> mp;\n        int n = nums.size(), maxGap = INT_MAX, gap;\n        \n        for(int i = 0; i < n; i++) mp[nums[i]].push_back(i);\n        \n        for(auto x : mp)\n        {\n            gap = INT_MIN;\n            auto arr = x.second;\n            \n            for(int i = 0; i < arr.size(); i++)\n            {\n                if(i == arr.size() - 1)\n                    gap = max(gap, arr[0] + (n - arr[i] - 1));\n                else\n                    gap = max(gap, arr[i + 1] - arr[i] - 1);\n                    \n            }\n            maxGap = min(maxGap, gap);\n        }\n        return ceil((float)maxGap / 2);\n    }\n};\n```
['C++']