Beats 100%||Explained|| unordered_map ||  Intution
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\n\n# Complexity\n- T
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n![contestque.jpeg](https://assets.leetcode.com/users/images/868e3924-91b2-4cc0-8cca-173e87e1165e_1691253434.8767924.jpeg)\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ --> \n    O(N)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(N)\n\n# Code\n```\nclass Solution {\npublic:\n    int minimumSeconds(vector<int>& nums) {\n        unordered_map<int,vector<int>> umap;\n        for(int i=0;i<nums.size();i++){\n            umap[nums[i]].push_back(i);\n        }\n        int mn=ceil(double(nums.size()-1)/2);\n        \n        for(auto i: umap){\n            if(i.second.size()==1) continue;\n            else{\n                int dist=INT_MIN;\n                for(int k=1;k<i.second.size();k++){\n                    dist=max(i.second[k]-i.second[k-1]-1,dist);\n                }\n                dist=max((int)(nums.size()+i.second[0]-i.second[i.second.size()-1]-1),dist);\n                // cout<<i.first<<" "<<dist<<endl;\n                mn=min((int)ceil(double(dist)/2),mn);\n            }\n        }\n        return mn;\n    }\n};\n```
['Math', 'Ordered Map', 'C++']