5 Lines Min-Max in Erlang
Approach\n Describe your approach to solving the problem. \nLet $D(v)$ be the longest distance of the element $v$ in the circular array. The solution is simply 
# Approach\n<!-- Describe your approach to solving the problem. -->\nLet $D(v)$ be the longest distance of the element $v$ in the circular array. The solution is simply the smallest $\\lfloor \\frac{D(v)}{2} \\rfloor $ for all $v$ in the array. \n\nTherefore, my algorithm scans each element in the array with two hashtables, one for storing the latest position of each value, and the other for storing the maximum distance of each value. Finally, get the smallest one and divide it by 2. \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# Code\n```\n-spec minimum_seconds(Nums :: [integer()]) -> integer().\nminimum_seconds(Nums) -> solve(Nums ++ Nums, 0, #{}, #{}) div 2.\nsolve([], _, _, Distance) -> lists:min(maps:values(Distance));\nsolve([H|T], I, Counter, Distance) -> \n    D = I - maps:get(H, Counter, I),\n    solve(T, I+1, Counter#{H => I}, Distance#{H => max(D, maps:get(H, Distance, 0))}).\n```
['Array', 'Hash Table', 'Recursion', 'Erlang']