✅[Python] Simple and Clean, beats 88%✅
Please upvote if you find this helpful. \u270C\n\n\nThis is an NFT\n\n# Intuition\nThe problem asks us to modify a given string s by performing operations on it
### Please upvote if you find this helpful. \u270C\n<img src="https://assets.leetcode.com/users/images/b8e25620-d320-420a-ae09-94c7453bd033_1678818986.7001078.jpeg" alt="Cute Robot - Stable diffusion" width="200"/>\n\n*This is an NFT*\n\n# Intuition\nThe problem asks us to modify a given string `s` by performing operations on it. In one operation, we can replace a character in `s` with another lowercase English letter. Our task is to make `s` a palindrome with the minimum number of operations possible. If there are multiple palindromes that can be made using the minimum number of operations, we should make the lexicographically smallest one.\n\n# Approach\n1. Convert the string `s` into a list of characters `s_list`.\n\n2. Initialize two pointers `l` and `r` at the start and end of the list respectively.\n\n3. Enter a while loop that runs until `l` is greater than or equal to `r`.\n\n4. Inside the loop, check if the character at index `l` is smaller than the character at index `r`. \n\n1. If it is, replace the character at index `r` with the character at index `l`.\n\n1. If the character at index `l` is greater than the character at index `r`, replace the character at index `l` with the character at index `r`.\n\n1. Increment `l` by 1 and decrement `r` by 1.\n\n1. After the loop ends, join the list back into a new string `new_s` and return it.\n\n# Complexity\n- Time complexity: $$O(n)$$ where n is the length of string s.\n- Space complexity: $$O(n)$$ where n is the length of string s.\n\n# Code\n```\nclass Solution:\n    def makeSmallestPalindrome(self, s: str) -> str:\n        s_list = list(s)\n        l,r = 0, len(s_list)-1\n        while l<r:\n            if ord(s_list[l]) < ord(s_list[r]):\n                s_list[r] = s_list[l]\n            elif ord(s_list[l]) > ord(s_list[r]):\n                s_list[l] = s_list[r]\n            l+=1\n            r-=1\n        new_s = \'\'.join(s_list)\n        return new_s        \n```
['Two Pointers', 'String', 'Python', 'Python3']