Java Simple solution. HashMap O(N)
Intuition\nFor each distinct number, the distance between its occurrance divided by two is the number of times to populate it throughout the whole array.\n\n# A
# Intuition\nFor each distinct number, the distance between its occurrance divided by two is the number of times to populate it throughout the whole array.\n\n# Approach\nUse two HashMap, one to keep track of each number\'s last position. Another one to keep track of the max distance of each unique in the array. If a number only appeared once, the length of array will end up to be the value.\n\nAfterwards, compare each max distance and find the shortest one. Half of it is the result.\n\nGood news of this solution is that it\'s O(N). I think you can combine the two HashMap into one, like change the value into a int[]. But this is what I came up with during the contest.\n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(N)\n\n# Code\n```\nclass Solution {\n    public int minimumSeconds(List<Integer> nums) {\n        HashMap<Integer, Integer> map = new HashMap();\n        HashMap<Integer, Integer> dist = new HashMap();\n        int n = nums.size();\n        \n        for(int i = 0; i < 2 * n; i++) {\n            int curr = nums.get(i % n);\n            \n            if(map.containsKey(curr) && map.get(curr) != i) {\n                int maxDist = i - map.get(curr);\n                if(map.get(curr) > i) maxDist = n + map.get(curr) - i;\n\n                // found larger distance\n                if(!dist.containsKey(curr) || maxDist > dist.get(curr)) {\n                    dist.put(curr, maxDist);\n                }\n            }\n            map.put(curr, i);\n        }\n        \n        //System.out.println(dist);\n        \n        int res = Integer.MAX_VALUE;\n        for(int i : dist.keySet()) {\n            // 3 -> 1, 2 -> 1\n            res = Math.min(res, dist.get(i) / 2);\n        }\n        return res;\n    }\n}\n```
['Java']