Easy to Understand Java Code || Beats 100%
Complexity\n- Time complexity:\nO(n)\n- Space complexity:\nO(n)\n# Code\n\nclass Solution {\n    public String breakPalindrome(String palindrome) {\n        cha
# Complexity\n- Time complexity:\nO(n)\n- Space complexity:\nO(n)\n# Code\n```\nclass Solution {\n    public String breakPalindrome(String palindrome) {\n        char[] s = palindrome.toCharArray();\n        for(int i=0; i<s.length/2; i++){\n            if(s[i] != \'a\'){\n                s[i] = \'a\';\n                return new String(s);\n            }\n        }\n\n        s[s.length-1] = \'b\';\n        return s.length < 2 ? "" : new String(s); \n    }\n}\n```
['Java']