c++ solution
\nclass Solution {\npublic:\n    vector<long long>findPalindrom(long long num){\n        string s=to_string(num);\n        int n =s.size();\n        unordered_s
```\nclass Solution {\npublic:\n    vector<long long>findPalindrom(long long num){\n        string s=to_string(num);\n        int n =s.size();\n        unordered_set<long long>st;\n        st.insert(pow(10,n)+1);\n        st.insert(pow(10,n-1)-1);\n        int mid=(n+1)/2;\n        long long prefix=stoll(s.substr(0,mid));\n        for(int i=-1;i<=1;i++){\n            string front=to_string(prefix+i);\n            string back="";\n            if(n&1){\n                back=front.substr(0,front.size()-1);\n            }else{\n                back=front.substr(0,front.size());\n            }\n            reverse(back.begin(),back.end());\n            front+=back;\n            st.insert(stoll(front));\n        }\n        vector<long long>v;\n        for(auto &it:st){\n            v.push_back(it);\n        }\n        return v;\n    }\n    bool isPalindron(long long x){\n        long long y=0;\n        while(x){\n            y=y*10+x%10;\n            x/=10;\n        }\n        return x==y;\n    }\n    long long minimumCost(vector<int>& nums) {\n        int n=nums.size();\n        sort(nums.begin(),nums.end());\n        long long medien = (n&1)?(nums[(n-1)/2]+nums[n/2])/2:nums[n/2];\n        vector<long long>v=findPalindrom(medien);\n        if(isPalindron(medien)) v.push_back(medien);\n        long long ans=1e18;\n        for(auto &it:v){\n            long long cost=0;\n            for(int i=0;i<n;i++){\n                cost+=abs(nums[i]-it);\n            }\n            ans=min(ans,cost);\n        }\n        return ans;\n    }\n};\n```
['Greedy', 'C', 'C++']