EASY SOLUTION USING LOOPS || BRUTE FORCE BEATING 100% || C++ & JAVA SOLUTION
IntuitionTo convert the given string into a palindrome with the minimum number of operations, we need to ensure that the string reads the same forward and backw
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
To convert the given string into a palindrome with the minimum number of operations, we need to ensure that the string reads the same forward and backward.
For each character s[i] in the first half, it should match its corresponding character s[n-i-1] in the second half.
If they are different, we must replace one of them.
To ensure lexicographically smallest palindrome, we always choose the smaller character when making replacements.
# Approach
<!-- Describe your approach to solving the problem. -->
1. **Two Pointers:** Use one pointer at the left (i) and another at the right (n-i-1).
2. **Replace Characters:**
    - If s[i] != s[n-i-1], replace the larger one with the smaller one.
    - This guarantees minimal changes and maintains lexicographical order.
3. **Continue Until Middle:** Process characters until the middle of the string is reached.

# Complexity
- Time complexity: O(n)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(n)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
**IN JAVA**
![image.png](https://assets.leetcode.com/users/images/272546ef-6945-4057-9d7f-12e09921e427_1742033319.0282185.png)

**IN C++**
![image.png](https://assets.leetcode.com/users/images/91482789-c5a7-4ba8-91ff-479fc89fb485_1742033434.4294922.png)

# Code
```JAVA []
class Solution {
    public String makeSmallestPalindrome(String s) {
        char[] chars=s.toCharArray();
        int n=chars.length;
        for (int i = 0; i < n / 2; i++) {
            int j = n - i - 1;
            if (chars[i] != chars[j]) {
                chars[i] = chars[j] = (char) Math.min(chars[i], chars[j]);
            }
        }
        return new String(chars);
    }
}
```
```CPP []
class Solution {
public:
    string makeSmallestPalindrome(string s) {
        int n = s.size();
        for (int i = 0; i < n / 2; i++) {
            int j = n - i - 1;
            if (s[i] != s[j]) {
                s[i] = s[j] = min(s[i], s[j]);
            }
        }
        return s;
    }
};
```
['Two Pointers', 'String', 'Greedy', 'C++', 'Java']