Easy Solution 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. \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 {\npublic:\n    bool isPalindrome(int n) \n    { \n        int reverse = 0; \n        int temp = n; \n        while (temp != 0) { \n            reverse = (reverse * 10) + (temp % 10); \n            temp = temp / 10; \n        } \n        return (reverse == n);\n    }\n\n    long long minimumCost(vector<int>& nums) {\n        int n = nums.size();\n        sort(begin(nums), end(nums));\n        long long median = nums[n/2];\n        bool flag = false;\n        if (isPalindrome(median)) {\n            long long ans = 0;\n            for (int i = 0; i < n; i++) {\n                ans += abs(nums[i] - median);\n            }\n            return ans;\n        } else {\n            long long a = median, b = median;\n            while (true) {\n                if (isPalindrome(a)) break;\n                a--;\n            }\n            while (true) {\n                if (isPalindrome(b)) break;\n                b++;\n            }\n\n            long long ans1 = 0, ans2 = 0;\n            for (int i = 0; i < n; i++) {\n                ans1 += abs(nums[i] - a);\n                ans2 += abs(nums[i] - b);\n            }\n            return min(ans1, ans2);\n        }\n    }\n};\n\n```\n```\nUpvote (:\n```
['C++']