Easy Brute Force Approach
Intuition\n Describe your first thoughts on how to solve this problem. \nFind the nearest pallindrome to the median\n\n\n# Approach\n Describe your approach to 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFind the nearest pallindrome to the median\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nFind the pallindrome greater or smaller to the median. Find the total cost using both of the methods and return the minimum value.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(nlogn)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    bool isPallindrome(int x)\n    {\n        string s= to_string(x);\n        int n=s.size();\n        int i=0, j=n-1;\n        while(i<=j)\n        {\n            if(s[i++]!=s[j--])\n                return false;\n        }\n        return true;\n    }\n    long long minimumCost(vector<int>& nums) {\n        int n=nums.size();\n        sort(nums.begin(), nums.end());\n        int mid= nums[n/2];\n        //now find the next or prev nearest pallindrome to this mid;\n        int mid1=mid, mid2=mid;\n       \n        while(isPallindrome(mid1)==false)\n        {\n            mid1++;\n        }\n         while(isPallindrome(mid2)==false && mid2>0)\n        {\n            mid2--;\n        }\n        \n//         int d1= abs(mid1-mid);\n//         int d2= abs(mid2-mid);\n//       int d=0;\n//         if(d1<d2)\n//         {\n//             d=mid1;\n//         }\n//         else\n//             d=mid2;\n        \n        \n       long long sum1=0, sum2=0;\n        for(int i=0;i<n;i++)\n        {\n            sum1+=(long long)abs(nums[i]-mid1);\n                   sum2+=(long long)abs(nums[i]-mid2);\n        }\n        return min(sum1, sum2);\n        \n    }\n};\n```
['C++']