Easiest 2 Pointers Approach | Short code explained
Intuition\nWe need to make the string palindrome. Thus we need to compare first and last indices.\n\n# Approach\n- (step 1) Keep one index at beginning of strin
# Intuition\nWe need to make the string palindrome. Thus we need to compare first and last indices.\n\n# Approach\n- **(step 1)** Keep one index at beginning of string and other at the end.\n- **(case 1)** Update the first index to the character at last index if last index character is alphabetically smaller.\n- **(case 2)** Else update last index character to first index character.\n- **(step 3)** Increment and decrement the first and last indexes.\n\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 {\npublic:\n    string makeSmallestPalindrome(string s) {\n        int i=0, int j=s.size()-1; //Step 1\n        while(i<j){\n            if(s[i]<=s[j]) s[j]=s[i]; //Case 1\n            else s[i]=s[j]; //Case 2\n            i++,j--; //Step 3\n        }\n        return s;\n    }\n};\n```\n**Please upvote if it helped. Happy Coding!**
['C++']