C++  find max distance between two same numbers
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nfind max distance betwe
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nfind max distance between two same numbers\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(n)\n# Code\n```cpp []\n\nclass Solution {\npublic:\n    int minimumSeconds(vector<int>& nums) {\n        int n = int(nums.size());\n        unordered_map<int, vector<int>> appears;\n        for (int i = 0; i < n; ++i) appears[nums[i]].push_back(i);\n\n        int r=INT_MAX;\n        for(const auto& ap:appears)\n            r=min(r,maxDiff(ap.second,n)/2);\n\n       return r;\n    }\n\n    int maxDiff( const vector<int>& poses, int n) {\n        int max_diff = 0;\n        for(int i=1,n=int(poses.size());i<n;++i) \n          max_diff=max(max_diff,poses[i]-poses[i-1]);\n\n        max_diff=max(max_diff, poses[0]+n-poses.back());\n        return max_diff;\n    }\n};\n\n```
['C++']