Easy Solution with O(n) time complexity
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nStore all elements in m
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nStore all elements in map and find the gap between elements \n\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\n# Code\n```\nclass Solution {\npublic:\n    int minimumSeconds(vector<int>& nums) {\n        map<int,vector<int>> mp;\n        int n = nums.size();\n        for(int i = 0 ; i < n; i++){\n            mp[nums[i]].push_back(i);\n        }\n        int l,r,res=INT_MAX;\n        for(auto x: mp){\n            auto adj = x.second;\n            l = adj[0];\n            r = n-adj.back()-1;\n            l = (l+r+1)/2;\n            for(int i = 1 ; i < adj.size(); i++){\n                l = max(l,(adj[i]-adj[i-1])/2);\n            }\n            res = min(l,res);\n        }\n        return res;\n    }\n};\n```
['C++']