Easy solution in c++, Beats 92% people's runtime
Intuition\nBeats 92% people\'s runtime.\n Describe your first thoughts on how to solve this problem. \nTo find the minimum cost , we should find the palindrome 
# Intuition\nBeats 92% people\'s runtime.\n<!-- Describe your first thoughts on how to solve this problem. -->\nTo find the minimum cost , we should find the palindrome number which will be nearest to all the numbers compare to other palindrome numbers\n# Approach\n<!-- Describe your approach to solving the problem. -->\nFirst we will find median, then according to median , we will find nearest palindrome number , but in case suppose the number the 5376\nwhich is nearer to 5445 instead of 5335, so we should assumpt the case in which we will take two sides of mid numbers . Firs we will take mirror image of left part of array to make it palindrome.\nAnd for assumption case we will suppose the two sides of mid number.\n\n\n# Complexity\n- Time complexity:\no(nlogn)\n\n- Space complexity:\no(n)\n\n# Code\n```\nclass Solution {\npublic:\n    long long minimumCost(vector<int>& nums) {\n        int n=nums.size();\n        sort(nums.begin(),nums.end());\n        int sum;\n        if(n%2==0){\n           sum=(nums[(n-1)/2]+nums[(n+1)/2])/2;\n        }\n        else{\n            sum=nums[(n)/2];\n        }\n        cout<<sum<<endl;\n        vector<int> arr;\n        long long store=sum;\n        while(store){\n            arr.push_back(store%10);\n            store=store/10;\n        }\n        int m=arr.size();\n        for(int i=0;i<m/2;i++){\n            arr[i]=arr[m-1-i];\n        }\n        \n        if(m%2==0){\n            int temp=arr[m/2];\n            \n        int num=0;\n        // int k=0;\n        for(int i=0;i<m;i++){\n            num+=arr[i]*(pow(10,i));\n        }\n        long long ans=0;\n        for(int i=0;i<n;i++){\n            ans+=abs(nums[i]-num);\n        }\n        cout<<num<<endl;\n        int num1=0;\n        arr[(m-1)/2]=temp+1;\n        arr[m/2]=temp+1;\n        // int k=0;\n        for(int i=0;i<m;i++){\n            num1+=arr[i]*(pow(10,i));\n        }\n        cout<<num1<<endl;\n\n        long long ans1=0;\n        for(int i=0;i<n;i++){\n            ans1+=abs(nums[i]-num1);\n        }\n       ans=min(ans,ans1);\n\n       int num2=0;\n        arr[(m-1)/2]=temp-1;\n        arr[m/2]=temp-1;\n        // int k=0;\n        for(int i=0;i<m;i++){\n            num2+=arr[i]*(pow(10,i));\n        }\n        cout<<num2<<endl;\n        long long ans2=0;\n        for(int i=0;i<n;i++){\n            ans2+=abs(nums[i]-num2);\n        }\n        ans=min(ans,ans2);\n        return ans;\n        }\n        \n        else{\n            int num=0;\n    \n        for(int i=0;i<m;i++){\n            num+=arr[i]*(pow(10,i));\n        }\n        long long ans=0;\n        for(int i=0;i<n;i++){\n            ans+=abs(nums[i]-num);\n        }\n            \n       \n        \n        int yupi=arr[(m)/2];\n            \n        if(yupi!=0){\n        arr[(m)/2]=yupi-1;\n            \n            int num1=0;\n        for(int i=0;i<m;i++){\n            num1+=arr[i]*(pow(10,i));\n        }\n        long long ans1=0;\n        for(int i=0;i<n;i++){\n            ans1+=abs(nums[i]-num1);\n        }\n        ans=min(ans,ans1);\n            cout<<num1<<endl;\n        }\n            if(yupi!=9){\n        \n        arr[(m)/2]=yupi+1;\n            \n            int num2=0;\n    \n        for(int i=0;i<m;i++){\n            num2+=arr[i]*(pow(10,i));\n        }\n        long long ans2=0;\n        for(int i=0;i<n;i++){\n            ans2+=abs(nums[i]-num2);\n        }\n            ans=min(ans,ans2);\n                cout<<num2<<endl;\n            }\n            // cout<<num1<<" "<<num2<<endl;\n            // cout<<num<<endl;\n        return ans;\n    \n        }\n    }\n    \n};\n```
['C++']