swift solution using max diff b/w two elements
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n)\n\n- Space complexity:O(n)\n\n# Code\n```\nclass Solution {\n    func minimumSeconds(_ nums: [Int]) -> Int {\n        var nums = nums\n        var count = 0\n        var n = nums.count\n        var dict: [Int: [Int]] = [:]\n        var maxElement = 0 \n        for i in 0..<nums.count {\n            let num = nums[i]\n            dict[num, default: []].append(i)\n        }\n        var minEle = 0\n        var output = Int.max\n        for (key, value) in dict {\n            if value.count >= 2 {\n                var maxValue = 0\n                for i in 1..<value.count {\n                    maxValue = max(maxValue, value[i]-value[i-1]-1)\n                }\n                maxValue = max(maxValue, n-1-value[value.count-1]+value[0])\n                output = min(output, maxValue)\n            } else {\n                 output = min(output, n-1)\n            }\n        }\n         \n        return (output+1)/2\n    }\n}\n```
['Swift']