Easy Solution in Java | 8 ms - 100% beats | Fully Explained
\n\n# Approach\n\nTo solve the problem, we follow these steps:\n\n1. Convert the input string s into a character array arr for easy manipulation.\n2. Determine 
\n\n# Approach\n\nTo solve the problem, we follow these steps:\n\n1. Convert the input string `s` into a character array `arr` for easy manipulation.\n2. Determine the length of the array and store it in the variable `n`.\n3. Iterate over the array from the beginning (`i = 0`) to the middle (`i < n / 2`).\n4. Check if the characters at positions `i` and `j` (where `j = n - 1 - i`) are different.\n5. If the characters are different, replace both characters with the lexicographically smaller one.\n6. Finally, convert the modified character array `arr` back into a string and return it as the result.\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public String makeSmallestPalindrome(String s) {\n        char[] arr = s.toCharArray();\n        int n = arr.length;\n        for(int i = 0, j = n - 1; i < n / 2; i++, j--)\n            if(arr[i] != arr[j]){\n                char smallOne = (char) Math.min(arr[i], arr[j]);\n                arr[i] = arr[j] = smallOne;\n            }\n        return new String(arr);\n    }\n}\n```
['Array', 'Two Pointers', 'String', 'Java']