find median and both palindromic nearest to it.
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: O(N*log(N))\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 isPalindromic(int n){\n        int rNum=0;\n        int temp=n;\n\n        while(temp!=0){\n            int x = temp%10;\n            rNum = 10*rNum+x;\n            temp/=10;\n        }\n        return (rNum==n);\n    }\n    long long minimumCost(vector<int>& nums) {\n        sort(nums.begin(), nums.end());\n\n        int n=nums.size();\n\n        int median;\n\n        if(n%2!=0){\n            median = nums[n/2];\n        }\n        else{\n            median = (nums[(n/2)-1] + nums[n/2])/2;\n        }\n\n        int num1, num2;\n        int temp1=median, temp2=median;\n\n        while(temp1>0){\n            if(isPalindromic(temp1)==true){\n                num1=temp1;\n                break;\n            }\n            temp1--;\n        }\n\n        while(temp2<INT_MAX){\n            if(isPalindromic(temp2)==true){\n                num2=temp2;\n                break;\n            }\n            temp2++;\n        }\n\n        long long ans1=0, ans2=0;\n\n        for(int i=0; i<n; i++){\n            ans1 += abs(nums[i]-num1);\n            ans2 += abs(nums[i]-num2);\n            \n        }\n\n        return min(ans1, ans2);\n        \n    }\n};\n```
['C++']