Using HashMap + Easy to understand + Greedy Approach
Intuition\n Describe your first thoughts on how to solve this problem. \nTry to think in the way of spreading the flow of elements in both sides. So, to find mi
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTry to think in the way of spreading the flow of elements in both sides. So, to find minimum time to make all the element equal we need to find out the minimum of all the maximum spreading time of all the elements.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nUse hashmap to store the maximum spreading time of each element and their starting index and last index to find the spreadingg elements.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(N*log((N)))$$\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(N)$$\n# Code\n```\nclass Solution {\npublic:\n    int minimumSeconds(vector<int>& nums) {\n        int n = nums.size();\n        map<int,pair<int,pair<int,int>>>mp; // maxi, {st,last}\n        for(int i=0;i<n;i++){   \n            if(mp.find(nums[i])!=mp.end()){\n                int maxi = mp[nums[i]].first;\n                int st = mp[nums[i]].second.first;\n                int last = mp[nums[i]].second.second;\n                maxi = max(maxi,(i-last)/2);\n                last = i;\n                mp[nums[i]] = {maxi,{st,last}};\n            }else{\n               mp[nums[i]] = {0,{i,i}};\n            }\n        }\n        int ans = 1e9;\n        for(auto it:mp){\n            int maxi = it.second.first;\n            int st = it.second.second.first;\n            int end =it.second.second.second;\n            int temp = (st+n-end)/2;\n                maxi = max(maxi,temp);\n                ans = min(ans,maxi);\n        }\n        return ans;\n    }\n};\n\n\n\n\n// You may ignore it......\nif(reader.is_doubt==true){\n    cout<<"You can ask, without any hesitation"<<endl;\n}else{\n    cout<<"You can upvote this editorial!!!"<<endl;\n}\n\n\n```
['Array', 'Hash Table', 'Greedy', 'C++']