C++ EASY AND CLEAN SOLUTION
Code\n\nclass Solution {\npublic:\n    int minimumSeconds(vector<int>& arr) {\n        unordered_map<int,vector<int>> mp;\n        int n=arr.size(),mini=n-1;\n 
# Code\n```\nclass Solution {\npublic:\n    int minimumSeconds(vector<int>& arr) {\n        unordered_map<int,vector<int>> mp;\n        int n=arr.size(),mini=n-1;\n        for(int i=0;i<n;i++) mp[arr[i]].push_back(i);\n        for(auto it:mp){\n            vector<int> pos=it.second;\n            int len=pos.size();\n            int maxi=(n-1-pos[len-1])+pos[0];\n            for(int i=1;i<len;i++) maxi=max(maxi,pos[i]-pos[i-1]-1);\n            mini=min(mini,maxi);\n        }\n        return (mini+1)/2;\n    }\n};\n```
['C++']