Python 10 lines, 91 ms, 100% runtime, with explanation.
Approach\nFor every unique number track max gap between number occurencies.\nRecord the index of the first occurence of each number to consider the cyclic gap.\
# Approach\nFor every unique number track max gap between number occurencies.\nRecord the index of the first occurence of each number to consider the cyclic gap.\nThe answer is the min between the gaps divided by 2 and ceiled to int.\n\n# Complexity\n- Time complexity: $$O(n)$$\n- Space complexity: $$O(n)$$\n\n# Submission\nhttps://leetcode.com/problems/minimum-seconds-to-equalize-a-circular-array/submissions/1449597428/\n\n# Code\n```python3 []\nclass Solution:\n    def minimumSeconds(self, nums: List[int]) -> int:\n        # Keys are numbers, values are max gap between them\n        gaps = defaultdict(int)\n        # Indices of the first occurence of every num\n        frst = {}\n        # Indices of the previous occurence of every num\n        prev = {}\n        for i, num in enumerate(nums):\n            if num not in frst:\n                frst[num] = i\n            else:\n                # The actual gap is i - prev[num] - 1\n                # +1 is needed to make an implicit ceiling for gap / 2\n                gaps[num] = max(gaps[num], i - prev[num])\n            prev[num] = i\n        \n        # We need the min default value for case when\n        # nums does not contain any pairs\n        return min((max(frst[num] + len(nums) - prev[num], v) for num, v in gaps.items()), default=len(nums)) // 2\n\n```
['Python3']