C++ | Simple 0 ms 5 lines solution beats submitted solutions 100% in runtime and 90% in memory
IntuitionReplace the twin characters with the smaller one if they are not equal.ApproachParse the string character by character till the mid of the string. Comp
# Intuition
Replace the twin characters with the smaller one if they are not equal.

# Approach
Parse the string character by character till the mid of the string. Compare each character at a specific position from the beginning with the character at the same position from the end of the string. If the characters are not equal replace the lexicographically larger character with the lexicographically smaller character. Repeat this process till you reach the middle of the string.  
 
# Complexity
- Time complexity for `n` characters in the string: $$O(n)$$

- Space complexity for `n` characters in the string: $$O(1)$$

# Code
```cpp []
class Solution {
public:
    string makeSmallestPalindrome(string s) {
        const int n = s.size();
        for (int i=0; i<n/2; ++i) {
            if (s[i] == s[n-1-i])   continue;
            if (s[i] < s[n-1-i])    s[n-1-i] = s[i];
            else s[i] = s[n-1-i];
        }

        return s;
    }
};
```
['C++']