Simple C# solution
\n\n# Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \n
\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n\n# Code\n```\n\tpublic class Solution\n\t{\n\t\tprivate int CalculateIntervalMinification(int interval)\n\t\t{\n\t\t\tvar res = interval / 2;\n\t\t\tif (interval % 2 == 1)\n\t\t\t{\n\t\t\t\tres++;\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\n\t\tpublic int MinimumSeconds(IList<int> nums)\n\t\t{\n\t\t\tIDictionary<int, IList<int>> val2Indices = new Dictionary<int, IList<int>>();\n\t\t\tfor(var i = 0; i < nums.Count; i++)\n\t\t\t{\n\t\t\t\tif(!val2Indices.ContainsKey(nums[i]))\n\t\t\t\t{\n\t\t\t\t\tval2Indices[nums[i]] = new List<int>();\n\t\t\t\t}\n\n\t\t\t\tval2Indices[nums[i]].Add(i);\n\t\t\t}\n\n\t\t\tint res = int.MaxValue;\n\n\t\t\tforeach (var kv in val2Indices)\n\t\t\t{\n\t\t\t\tvar list = kv.Value;\n\t\t\t\tvar cand = 0;\n\n\t\t\t\tvar i = 1;\n\n\t\t\t\twhile (i < list.Count)\n\t\t\t\t{\n\t\t\t\t\twhile(i < list.Count && list[i] == list[i - 1] + 1)\n\t\t\t\t\t{\n\t\t\t\t\t\ti++;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (i < list.Count)\n\t\t\t\t\t{\n\t\t\t\t\t\tcand = Math.Max(cand, CalculateIntervalMinification(list[i] - list[i - 1] - 1));\n\t\t\t\t\t\ti++;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tvar head = list[0];\n\t\t\t\tvar tail = nums.Count - list[list.Count - 1] - 1;\n\t\t\t\tcand = Math.Max(cand, CalculateIntervalMinification(head + tail));\n\n\t\t\t\tres = Math.Min(res, cand);\n\t\t\t}\n\n\t\t\treturn res;\n\t\t}\n\t}\n```
['C#']