Elemental Convolution
IntuitionGet consecutive differences for each elementApproachComplexity

Time complexity:
O(n)


Space complexity:
O(n)

Code
# Intuition
Get consecutive differences for each element

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
O(n)

- Space complexity:
O(n)

# Code
```javascript []
/**
 * @param {number[]} nums
 * @return {number}
 */
var minimumSeconds = function (nums) {
  let map = new Map();
  for (let n = 0; n < nums.length; n++) {
    if (map.has(nums[n])) {
      let a = map.get(nums[n]);
      a.push(n);
    } else {
      map.set(nums[n], [n]);
    }
  }
  let numer = Array.from(map.keys());
  let res = Infinity;
  for (let n of numer) {
    let a = map.get(n);
    if (a.length === 1) {
      res = Math.min(res, Math.max(a[0], nums.length - 1 - a[0]));
    } else {
      let f = a[0];
      let l = a[a.length - 1];
      let maxdiff = Math.ceil((f + (nums.length - 1 - l)) / 2);
      for (let e = 1; e < a.length; e++) {
        maxdiff = Math.max(maxdiff, Math.ceil((a[e] - a[e - 1] - 1) / 2));
      }
      res = Math.min(res, maxdiff);
    }
  }

  return res;
};
```
['JavaScript']