Simple Java Solution |  Easy to understand | Self explanatory
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public long minimumCost(int[] nums) {\n        Arrays.sort(nums);\n        \n        int med = (int)(findMedian(nums));\n        int medPalin1 = findNearestSmallerPalindrome(med);\n        int medPalin2 = findNearestLargerPalindrome(med);\n        \n        \n        long fin1 = 0;\n        long fin2 = 0;\n        \n        for(int i=0; i<nums.length; i++){\n            fin1 += Math.abs(nums[i] - medPalin1);\n            fin2 += Math.abs(nums[i] - medPalin2);\n        }\n        \n        return Math.min(fin1, fin2);\n    }\n    \n     public static double findMedian(int[] array) {\n\n        int length = array.length;\n\n        if (length % 2 == 1) {\n            return array[length / 2];\n        } else {\n            int mid1 = array[(length - 1) / 2];\n            int mid2 = array[length / 2];\n            return (double) (mid1 + mid2) / 2.0;\n        }\n    }\n    \n    public static boolean isPalindrome(int num) {\n        String numStr = Integer.toString(num);\n        return numStr.equals(new StringBuilder(numStr).reverse().toString());\n    }\n\n    public static int findNearestSmallerPalindrome(int num) {\n        int smaller = num;\n\n        while (true) {\n            if (isPalindrome(smaller)) {\n                return smaller;\n            }\n\n            smaller--;\n        }\n    }\n    \n    public static int findNearestLargerPalindrome(int num) {\n        int larger = num;\n\n        while (true) {\n            if (isPalindrome(larger)) {\n                return larger;\n            }\n\n            larger++;\n        }\n    }\n    \n}\n```
['Java']