Given a palindromic string of lowercase English letters palindrome, replace exactly one character with any lowercase English letter so that the resulting string is not a palindrome and that it is the lexicographically smallest one possible.

Return the resulting string. If there is no way to replace a character to make it not a palindrome, return an empty string.

A string a is lexicographically smaller than a string b (of the same length) if in the first position where a and b differ, a has a character strictly smaller than the corresponding character in b. For example, "abcc" is lexicographically smaller than "abcd" because the first position they differ is at the fourth character, and 'c' is smaller than 'd'.

&nbsp;
Example 1:

Input: palindrome = "abccba"
Output: "aaccba"
Explanation: There are many ways to make "abccba" not a palindrome, such as "zbccba", "aaccba", and "abacba".
Of all the ways, "aaccba" is the lexicographically smallest.


Example 2:

Input: palindrome = "a"
Output: ""
Explanation: There is no way to replace a single character to make "a" not a palindrome, so return an empty string.


&nbsp;
Constraints:


	1 &lt;= palindrome.length &lt;= 1000
	palindrome consists of only lowercase English letters.


class Solution(object):
    def breakPalindrome(self, palindrome):
        """
        :type palindrome: str
        :rtype: str
        """
        s = palindrome
        palindrome = [ch for ch in s]
        if len(palindrome) == 1:
            return ""
        
        for i in range(len(palindrome)//2):
            if palindrome[i] != 'a':
                palindrome[i] = 'a'
                return "".join(palindrome)
        palindrome[-1] = 'b'
        return "".join(palindrome)
        
        
                
                
class Solution {
    public String breakPalindrome(String palindrome) {
        
        int left = 0;
        int right = palindrome.length()-1;
        
        if(palindrome.length()==1)
            return "";
        
        while(left<right){
            
            char c = palindrome.charAt(left);
            
            if(c!='a'){
                StringBuilder sb = new StringBuilder(palindrome);
                sb.setCharAt(left,'a');
                return sb.toString();
            } 
            else{
                left++;
                right--;
            }
            
        
        }
       
        // aaaa
        // aba
        
        
              StringBuilder sb = new StringBuilder(palindrome);
                sb.setCharAt(palindrome.length()-1,'b');
                return sb.toString();
        
    
    }
}
class Solution {
public:
    string breakPalindrome(string palindrome) {
        int n = palindrome.size();
        string res = "";
        if(n==1){
            return res;
        }
        int i = 0;
        while(i<n){
            if(n%2!=0 && i==n/2){
                i++;
                continue;
            }
            if(palindrome[i] != 'a'){
                palindrome[i] = 'a';
                break;
            }
            i++;
        }
        if(i==n){
            palindrome[i-1] = 'b';
        }
        return palindrome;
    }
};
var breakPalindrome = function(palindrome) {
    // domain n / 2 k pehlay
    palindrome = palindrome.split('');
    const len = palindrome.length;
    if(len == 1) return "";
    const domain = Math.floor(len / 2);
    let firstNonAChar = -1, lastAChar = -1;
    for(let i = 0; i < domain; i++) {
        if(palindrome[i] != 'a') {
            firstNonAChar = i;
            break;
        }
    }
    if(firstNonAChar == -1) {
        palindrome[len - 1] = 'b';
    } else palindrome[firstNonAChar] = 'a';
    return palindrome.join('');
};
Break a Palindrome