Max Gap || Simple C++ solution using Map
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \njust calculate the max 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\njust calculate the max distance of each element with the same value at other index in both left and right direction.\nAnd now --\n```\nans = min(ans, maxDist/2);\n```\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    \n    int minimumSeconds(vector<int>& nums) {\n        \n        int n=nums.size();\n        map<int, int> mp;\n        map<int, int> gap;\n        \n        for(int i=0; i<n; i++){\n            mp[nums[i]] = i;\n        }\n        for(int i=0; i<n; i++){\n            gap[nums[i]] = max(gap[nums[i]],  (i+n)-mp[nums[i]]);\n            mp[nums[i]] = i+n;\n        }\n        \n        mp.clear();\n        for(int i=n-1; i>=0; i--){\n            mp[nums[i]] = i+n;\n        }\n        for(int i=n-1; i>=0; i--){\n            gap[nums[i]] = max(gap[nums[i]],  mp[nums[i]]-i);\n            mp[nums[i]] = i;\n        }\n        \n        int mn = 1e9;\n        for(int i=0; i<n; i++){\n            mn = min(mn, gap[nums[i]]/2);\n        }\n        return mn==1e9 ? 0 : mn;\n        \n    }\n};\n```
['Hash Table', 'C++']