Java || Map || Math
Code\n\nclass Solution {\n    public int minimumSeconds(List<Integer> nums) {\n        \n        int n = nums.size();\n        int seconds = n;\n        Map<Int
# Code\n```\nclass Solution {\n    public int minimumSeconds(List<Integer> nums) {\n        \n        int n = nums.size();\n        int seconds = n;\n        Map<Integer,List<Integer>> mp = new HashMap<>();\n        for(int i = 0;i<n;i++){\n            if(!mp.containsKey(nums.get(i))){\n                mp.put(nums.get(i), new ArrayList<>());\n            }\n            var ls = mp.get(nums.get(i));\n            ls.add(i);\n            mp.put(nums.get(i), ls);\n        }\n\n        for(var it : mp.entrySet()){\n            int mxDiff = 0;\n            var ls= it.getValue();\n            int sz = ls.size();\n            for(int i = 0;i<sz-1;i++){\n                int noOfEle = ls.get(i+1)-ls.get(i)-1;\n                int reqSec = (int)Math.ceil((double)noOfEle/(double)2);\n                mxDiff = Math.max(mxDiff, reqSec);\n            }\n            int noOfEle = n-1-ls.get(sz-1)+ls.get(0);\n            int reqSec = (int)Math.ceil((double)noOfEle/(double)2);\n            mxDiff = Math.max(mxDiff, reqSec);\n            seconds = Math.min(seconds, mxDiff);\n            System.out.println(mxDiff);\n        }\n        return seconds;\n    }\n}\n```
['Hash Table', 'Math', 'Java']