Using median!
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nfind the median! and ac
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nfind the median! and according to it find the palindrome number smaller than median and similarly find the palindrome number greater than median!\nThen according to smaller and larger palindrome number find the total of all the elements in the array!!\nAnd then return the minimum cost.\n\nDone..You are good to go!\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)$$ -->\nO(n)\n\n# Code\n```\nclass Solution {\npublic:\n    bool ispalin(string str)\n    {\n        int n = str.size();\n            \n        for(int i = 0;i<n/2;i++)\n        {\n            if(str[i] != str[n-1-i])\n                return false;\n        }\n        return true;\n    }\n    \n    long long minimumCost(vector<int>& nums) {\n        \n        sort(nums.begin(),nums.end());\n        \n        int n = nums.size();\n        int x = nums[n/2];\n        int y = x;\n        \n        while(ispalin(to_string(x)) == false)\n        {\n            x--;\n        }\n        while(ispalin(to_string(y)) == false)\n        {\n            y++;\n        }\n        \n        long long cost1 = 0,cost2 = 0;\n        for(int i = 0;i<n;i++)\n        {\n            cost1 += abs(nums[i]-x);\n            cost2 += abs(nums[i]-y);\n        }\n        \n        \n        return min(cost1,cost2);  \n    }\n};\n```
['C++']