✅✅ Beats 100% || Greedy || Easy Solution
Approach1. Handle Edge Case
If the palindrome has only one character, it's impossible to break it, so return "".
2. Try to Replace the First Non-'a' Character
I
# Approach

### **1. Handle Edge Case**
- If the palindrome has only **one character**, it's impossible to break it, so return `""`.

### **2. Try to Replace the First Non-'a' Character**
- Iterate through the **first half** of the string.
- If we find a character **not equal to 'a'**, replace it with **'a'** (smallest lexicographical change) and return the modified string.

### **3. If the String is All 'a's**
- The palindrome is something like `"aaa"`, `"aaaa"`, etc.
- The only way to **break the palindrome** while keeping it lexicographically smallest is by changing the **last character** to `'b'`.

# Complexity:
- **Time Complexity:** `O(N)` (single pass).
- **Space Complexity:** `O(1)` (modifying in-place).

# Code
```cpp []
class Solution {
public:
    string breakPalindrome(string palindrome) {
        int n= palindrome.length();
        if(n==1) return "";
        for(int i=0;i<n/2;i++){
            char ch=palindrome[i];
            if(ch!='a'){
                palindrome[i]='a';
                return palindrome;
            }
        }
        palindrome[n-1]='b';
        return palindrome;
    }
};
```
# Have a Good Day 😊 UpVote?
['String', 'Greedy', 'C++']