Explaination C++ using map.
Intuition\n#### What to think when you see the question \n\nGiven that \n1. we need to make all numbers 0 and\n2. that a number can influence its immediate neig
# Intuition\n#### What to think when you see the question \n\nGiven that \n1. we need to make all numbers 0 and\n2. that a number can influence its immediate neighbours in one second.\n\nHow much time will a number at index i at one end of the array take to influence the farthest index.\n\n\n# Approach\n\nIt comes out to be ceil(nums.size()/2). when all numbers are unique \n#### [ a, b, c, d, e, f, g ]  \nfarthest index from a in a circular manner is index of d or e . (distance = 3).\n\nIf a number occurs more than one time eg : \n#### arr =  [ a, b, c, d, e, f, g, h, c, i, j ] \n n=arr.size() = 11\n\nTo handle circular array case  we can consider \'c\' occurs at index 2+n = 2+11 = 13\n\n\'c\' occurs at index 2, 8 , 13;\n\nFind **maximum gap** between any two consecutive occurrences of \'c\'.\n\nDo this for every unique element \nWe need to take minimum of the maximum gaps .\n\nThis mingap is will be influenced in time ceil(mingap/2.0) seconds.\n\n\n\n# Complexity\n- Time complexity:\n$$O(n)$$\n\n- Space complexity:\n$$O(n)$$ (Storing all indexes after all)\n\n# Code with comments\n```\nclass Solution {\npublic:\n    int minimumSeconds(vector<int>& nums) {\n        // stores all indexes of  every unique element\n        unordered_map<int, vector<int>> indexes;\n    \n        int n = nums.size();\n        for(int i = 0; i<n; i++){\n            indexes[nums[i]].push_back(i);\n        }\n\n        // minimum of all { maximum gap for a number}\n        int mingap = n;\n        for(auto p: indexes){\n            int num = p.first;\n            // all indexes of num\n            vector<int> indexs = p.second;\n            indexs.push_back(indexs[0]+n);\n\n            int gap = 0;\n            // calculating maximum gap of two consecutive appearance of num\n            for(int i = 0; i<indexs.size()-1; i++){\n                gap = max(gap  , indexs[i+1]-indexs[i]-1);\n            }\n            mingap = min(gap, mingap);\n        }\n        // minimum time it takes to making all numbers equal\n        return ceil(mingap/2.0);\n    }\n};\n```\n# Cleaner Code\n```\nclass Solution {\npublic:\n    int minimumSeconds(vector<int>& nums) {\n        unordered_map<int, vector<int>> indexes;\n        int n = nums.size();\n        for(int i = 0;i<n ; i++){\n            indexes[nums[i]].push_back(i);\n        }\n        int mingap = n;\n        for(auto p: indexes){\n            int num = p.first;\n            vector<int> indexs = p.second;\n            indexs.push_back(indexs[0]+n);\n\n            int gap = 0;\n            for(int i = 0; i<indexs.size()-1; i++){\n                gap = max(gap  , indexs[i+1]-indexs[i]-1);\n            }\n            mingap = min(gap, mingap);\n        }\n        return ceil(mingap/2.0);\n    }\n};\n```
['C++']