Two Pointer || Very easy to understand || Java
\n# Approach\n Describe your approach to solving the problem. \n- Take two pointers, one at the 0th index and one at last index.\n- Check if the characters at b
\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- Take two pointers, one at the 0th index and one at last index.\n- Check if the characters at both pointers are same or not.\n- If not same, then check which character is lexicographically smaller.\n- Change the bigger character to smaller character.\n- Increment the first pointer and decrease the second one.\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public String makeSmallestPalindrome(String s) {\n        int i = 0, j = s.length()-1;\n        while(i < j) {\n            if(s.charAt(i) != s.charAt(j)) { \n                if(s.charAt(i) < s.charAt(j)) { //Checking the lexicographically smaller character\n                    s = s.substring(0, j) + s.charAt(i) + s.substring(j+1); //changing the bigger character to smaller one\n                }\n                else {\n                    s = s.substring(0, i) + s.charAt(j) + s.substring(i+1);\n                }\n            }\n            i++;\n            j--;\n        }\n        return s;\n    }\n}\n```
['Two Pointers', 'String', 'Java']