Easy C++ Solution ✅✅ | Maximum gap between similar element
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nJust find the maximum g
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nJust find the maximum gap between similar element and the answer will be minimum of all maximum gap.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int minimumSeconds(vector<int>& nums) {\n         int n=nums.size();\n        map<int,int> mp,g;\n        map<int,pair<int,int>> f;\n        for(int i=0;i<n;i++){\n            if(mp.find(nums[i])!=mp.end()){\n                if(g.find(nums[i])!=g.end()){\n                    g[nums[i]]=max(g[nums[i]],(i-mp[nums[i]]-1));\n                }\n                else g[nums[i]]=(i-mp[nums[i]]-1);\n            }\n            mp[nums[i]]=i;\n            if(f.find(nums[i])!=f.end()){\n                f[nums[i]]={f[nums[i]].first,i};\n            }\n            else f[nums[i]]={i,i};\n        }\n        for(auto k:f){\n            g[k.first]=max(g[k.first],(k.second.first+n-1-k.second.second));\n        }\n        int ans=INT_MAX;\n        for(auto k:g){\n            if(k.second%2!=0){\n                ans=min(ans,k.second/2+1);\n            }\n            else ans=min(ans,k.second/2);\n        }\n        return ans;\n    }\n};\n```
['Ordered Map', 'C++']