Easy JS solution
\n\n# Code\n\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar minimumSeconds = function(nums) {\n    // find max distance to number that is not th
![image.png](https://assets.leetcode.com/users/images/4c8e17d9-0ad3-428a-91cf-0137ea59c530_1716025141.3180327.png)\n\n# Code\n```\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar minimumSeconds = function(nums) {\n    // find max distance to number that is not the same\n    const hashMap = new Map()\n    for (let i = 0; i < nums.length; i++) {\n        let num = nums[i]\n        if (hashMap.has(num)) {\n            let indexes = hashMap.get(num)\n            indexes.push(i)\n            hashMap.set(num, indexes)\n        } else {\n            hashMap.set(num, [i])\n        }\n    }\n    let answer = Infinity\n    hashMap.forEach((indexes, num) => {\n        let maxDistForNum = -1 * Infinity\n        let firstIndex = indexes[0]\n        let lastIndex = indexes[indexes.length - 1]\n        maxDistForNum = Math.max(maxDistForNum, nums.length - lastIndex + firstIndex)\n        \n        for (let i = 1 ; i< indexes.length; i++) {\n            let prevIndex = indexes[i - 1]\n            let curIndex = indexes[i]\n            maxDistForNum = Math.max(maxDistForNum, curIndex - prevIndex)\n        }\n        answer = Math.min(answer, maxDistForNum)\n    })\n    return Math.floor(answer / 2)\n};\n```
['JavaScript']