Simple java Traversal
\n    public String breakPalindrome(String palindrome) {\n        int n = palindrome.length();\n        if(n<=1) {\n            return "";\n        }\n        i
```\n    public String breakPalindrome(String palindrome) {\n        int n = palindrome.length();\n        if(n<=1) {\n            return "";\n        }\n        int i=0;\n// Keep traversing until u find a character other than \'a\'.. or if u find another character but it is in the mid of palindrome, and changing it won\'t make any difference.\n        while(i<n && (palindrome.charAt(i)==\'a\' || (palindrome.charAt(i)>\'a\' && n%2!=0 && i==((n)/2)))) {\n            i++;\n        }\n// if i goes till n-1 i.e all characters are \'a\', replace last by b otherwise replace ith character by \'a\'          \n        return i<n-1?(palindrome.substring(0,i)+\'a\'+palindrome.substring(i+1)):palindrome.substring(0,n-1)+\'b\';\n    }\n```
[]