Brute Force for the Win
\n\n# Approach\n Describe your approach to solving the problem. \n\nFind the median then use brute force to find the smallest and largest palindromes. Calculate
\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\nFind the median then use brute force to find the smallest and largest palindromes. Calculate sum from using both values and then return the minimum.\n\n# Code\n```\nclass Solution {\npublic:\n    bool isPalin(int n){\n        int x=n,p=0;\n\n        while(x){\n            p = p*10 + x%10;\n            x/=10;\n        }\n        return p==n;\n    }\n    vector<int>findPalindrome(int m){\n        \n        int a=m,b=m;\n\n        while(1){\n            if(isPalin(a))break;\n            a++;\n        }\n        while(1){\n            if(isPalin(b))break;\n            b--;\n        }\n        return {b,a};\n    }\n    long long findSum(int x, vector<int>& nums){\n        long long s=0;\n        for(auto i:nums)s+=abs(i-x);\n        return s;\n    }\n    long long minimumCost(vector<int>& nums) {\n        sort(nums.begin(),nums.end());\n        int n = nums.size();\n        int m = nums[n/2];\n        auto res = findPalindrome(m);\n        long long s1 = findSum(res[0],nums);\n        long long s2 = findSum(res[1],nums);\n        return min(s1,s2);\n    }\n};\n```
['C++']