Easy & Intuitive || C++
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 k){\n        string str = to_string(k);\n        int i = 0, j = str.size()-1;\n        while (i < j){\n            if (str[i] != str[j]) return false;\n            i++, j--;\n        }\n        return true;\n    }\n\n    long long nearestPalindromeminus(int k){\n        int i = 0;\n        while (true){\n            if (isPalindrome(k-i)) return k-i;\n            i++;\n        }\n        return k;\n    }\n\n    long long nearestPalindromeplus(int k){\n        int i = 0;\n        while (true){\n            if (isPalindrome(k+i)) return k+i;\n            i++;\n        }\n        return k;\n    }\n\n\n    long long minimumCost(vector<int>& nums) {\n        int n = nums.size();\n        sort(nums.begin(), nums.end());\n        int mid;\n        if (n % 2 != 0) mid = nums[(n/2)];\n        else mid = (nums[(n-1)/2] + nums[(n+1)/2]) / 2;\n\n        long long val = nearestPalindromeminus(mid);\n        long long ans = 0;\n        for (int i = 0; i < nums.size(); i++){\n            ans += abs(val - nums[i]);\n        }\n\n        long long val2 = nearestPalindromeplus(mid);\n        long long ans2 = 0;\n        for (int i = 0; i < nums.size(); i++){\n            ans2 += abs(val2 - nums[i]);\n        }\n\n        return min(ans, ans2);\n    }\n};\n```
['C++']