Minimum cost to make array equalindromic
Code\n\nclass Solution:\n    def minimumCost(self, nums: List[int]) -> int:\n        def pal(i):\n            l = r = nums[i]\n            while (str(r) != str(
# Code\n```\nclass Solution:\n    def minimumCost(self, nums: List[int]) -> int:\n        def pal(i):\n            l = r = nums[i]\n            while (str(r) != str(r)[::-1]): r += 1\n            while l and (str(l) != str(l)[::-1]): l -= 1\n            return [l, r]\n\n        nums.sort()\n        n = len(nums)//2\n        \n        return min([sum(map(lambda x: abs(x-i), nums)) for i in set(pal(n-1)+pal(n))]) \n```\n\n# Code\n```\nclass Solution:\n    def minimumCost(self, nums: List[int]) -> int:\n        def pal(i, v=-1):\n            s = nums[i]\n            while s > 0 and (str(s) != str(s)[::-1]):\n                s += v\n            return s\n\n        d = Counter(nums)\n        nums = sorted(d.keys())\n        n = len(nums)//2\n\n        ans = float(\'inf\')\n        for i in set([pal(n-1, 1), pal(n-1), pal(n, 1), pal(n)]):\n            ans = min(ans, sum(map( lambda x: abs(x-i)*d[x], nums)))\n        \n        return ans \n```\n
['Python3']