⬆️🆙✅ Easy to understand & Best solution || 💯 Beats 100% of users with Java || O(n)💥👏🔥
Please upvote if my solution and efforts helped you.\n***\n\n\n## Approach - 2 Pointers Method\n1 pointer (i) from starting of the string\nanother pointer (j) f
# Please upvote if my solution and efforts helped you.\n***\n![proof.png](https://assets.leetcode.com/users/images/9a3165aa-00b4-470a-affd-9e55e2a472e6_1717950665.4987402.png)\n\n## Approach - 2 Pointers Method\n1 pointer (i) from starting of the string\nanother pointer (j) from the last of the string\nPut minimum element at the ith index and copy same value at the jth index.\n\n## Complexity\n- Time complexity:\n The time complexity is O(n). Because we are traversing the input string only once and till half length.\n\n- Space complexity:\nThe space complexity is O(n) because we are using char array of the string length size and a constant amount of space to store our variables, regardless of the size of the input array.\n\n## Code\n```\nclass Solution {\n    public String makeSmallestPalindrome(String s) {\n        char charArr[] = s.toCharArray();\n        int i = 0, j = s.length() - 1;\n        while (i < j) {\n            charArr[i] = (char) Math.min(charArr[i], charArr[j]);\n            charArr[j] = charArr[i];\n            i++;\n            j--;\n        }\n        return new String(charArr);\n    }\n}\n```\n![Leetcode-upvote.jpeg](https://assets.leetcode.com/users/images/e8c05dce-1b84-48c6-a2e9-0000f34b3c4b_1717950791.395676.jpeg)\n
['Array', 'Two Pointers', 'String', 'Java']