Simple Brute Force Approach || NLogN Time Complexity || Easy C++.
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    long long findCost(vector <int> &nums, int num){\n        long long cost = 0;\n        for(int c : nums)cost += abs(c-num);\n        return cost;\n    }\n    bool isPalindrome(int num){\n        int reverse = 0, temp = num;\n        while(temp){\n            reverse = reverse*10+temp%10;\n            temp /= 10;\n        }\n        return (reverse == num);\n    }\n    pair<int,int> findPalindrome(vector <int> &nums, int target){\n        // left palindrome, // right palindrome.\n        int num = target;\n        while(num && !isPalindrome(num))num--;\n        while(target && !isPalindrome(target))target++;\n        return {num, target};\n    }\npublic:\n    long long minimumCost(vector<int>& nums) {\n        sort(nums.begin(), nums.end());\n        int n = nums.size();\n        if(n%2){\n            // odd.\n            pair<int,int> ans = findPalindrome(nums, nums[n/2]);\n            return min({findCost(nums, ans.first), findCost(nums, ans.second)});\n        }\n        //even.\n        pair <int,int> ans1 = findPalindrome(nums, nums[n/2]);\n        pair <int,int> ans2 = findPalindrome(nums, nums[(n/2)-1]);\n        return min({findCost(nums, ans1.first), findCost(nums, ans1.second), findCost(nums, ans2.first), findCost(nums, ans2.second)});      \n    }\n};\n```
['C++']