median finding and nearest palindrome simple solution
\n# Code\n\n#define ll long long\n\nclass Solution {\npublic:\n    bool isPalindrome(long long num) {\n        long long reversedNum = 0;\n        long long ori
\n# Code\n```\n#define ll long long\n\nclass Solution {\npublic:\n    bool isPalindrome(long long num) {\n        long long reversedNum = 0;\n        long long originalNum = num;\n\n        while (num > 0) {\n            int digit = num % 10;\n            reversedNum = reversedNum * 10 + digit;\n            num /= 10;\n        }\n\n        return originalNum == reversedNum;\n    }\n\n    long long calculateCost(const vector<int>& nums, long long palindrome) {\n        ll curr = 0;\n        for (int j = 0; j < nums.size(); j++) {\n            curr += abs(palindrome - nums[j]);\n        }\n        return curr;\n    }\n\n    long long minimumCost(vector<int>& nums) {\n        sort(begin(nums), end(nums));\n        int n = nums.size();\n\n        ll ans = LLONG_MAX;\n        \n        ll leftPalindrome = nums[n / 2];\n        while (!isPalindrome(leftPalindrome)) {\n            leftPalindrome--;\n        }\n\n        ll rightPalindrome = nums[n / 2];\n        while (!isPalindrome(rightPalindrome)) {\n            rightPalindrome++;\n        }\n        \n        ll leftCost = calculateCost(nums, leftPalindrome);\n        ll rightCost = calculateCost(nums, rightPalindrome);\n\n        ans = min({ ans, leftCost, rightCost });\n\n        return ans;\n    }\n\n\n};\n```
['C++']