C++ || Unordered map easy solution
\n\n\n# Approach\n Describe your approach to solving the problem. \nApproach is to find the number which has least difference between the position at which it o
\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nApproach is to find the number which has least difference between the position at which it occurs . We will check the for all the numbers and solve it using map.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nThe time complexity of above code is O(n) as the vector inside the map just contains all the elements in the initial given vector.\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nSpace complexity is O(n) for unordered_map\n\n# Code\n```\nclass Solution {\npublic:\n    int minimumSeconds(vector<int>& nums) {\n        int n = nums.size();\n        unordered_map<int,vector<int>> m;\n        for(int i = 0 ; i < n ; i++){\n            m[nums[i]].push_back(i);\n            // storing the indexes at which given number occurs \n        }\n        int sol = 1e9;\n        for(auto p : m){\n            int res = 0;\n            vector<int> v = p.second;\n            for(int i = 0 ; i < v.size()-1; i++){\n                res = max(res,v[i+1]-v[i]);\n                // diff between same numbers at different positions \n            }\n            res = max(res,n-v[v.size()-1]+v[0]);\n            // this will be the difference between 1st and last index \n            sol = min(sol,res);\n        }\n        return sol/2;\n    }\n};\n```
['Hash Table', 'C++']