Excellent runtime with easy to understand application in C++
Intuition\n Describe your first thoughts on how to solve this problem. \nThe first intuition is to find the most even distribution of an element and then, start
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe first intuition is to find the most even distribution of an element and then, start with counting its time\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nApproach is basically to determine te maximum distance between indices of good elements. We consider all unique elements as good one by one and calculate maximum time required to turn th array as good. \n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->O(N)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->O(N^2)\n\n# Code\n```\nclass Solution {\npublic:\n        \nint help(const vector<int>& ar) {        \n    map<int, vector<int>> indexMap;\n    // Create a map to store indices of every element.\n    for (int i = 0; i < ar.size(); ++i) {\n        int element = ar[i];\n        indexMap[element].push_back(i);\n    }\n    int res = INT_MAX;\n    for (const auto& entry : indexMap) {\n        const vector<int>& vec = entry.second;\n        int last_first = (vec.front() + (ar.size()-1-vec.back()));\n        int temp = last_first/2; //Find distance between first and last occurence of a element(it is a circular array)\n        if(last_first%2 != 0){\n          temp++;\n        }\n        for(int i=0;i<vec.size()-1;i++){\n          // for every occurence maximum time to access all elements is calulated and stored\n          int num = (vec[i+1]-vec[i]);\n          int result = num / 2; \n          if(result>temp){\n            temp = result;\n          }\n        }\n        //minimum time by any element is stored as answer\n        if(temp<res){\n          res=temp;\n        }\n    }  \n    return res;\n}\n    int minimumSeconds(vector<int>& nums) {\n    int result = help(nums);\n    return result;\n    }\n};\n```
['C++']