JAVA || Greedy Solution||100% Faster Code
\n\nPLEASE UPVOTE IF YOU LIKE.\n\n\n# Complexity\n- Time complexity:\n O(N)\n\n- Space complexity:\n O(1)\n\n# Code\n\nclass Solution {\n    public String break
\n```\nPLEASE UPVOTE IF YOU LIKE.\n```\n\n# Complexity\n- Time complexity:\n O(N)\n\n- Space complexity:\n O(1)\n\n# Code\n```\nclass Solution {\n    public String breakPalindrome(String palindrome) {\n        int n = palindrome.length();\n        if (n == 1) return "";\n\n        StringBuilder sb = new StringBuilder(palindrome);\n        boolean flag = true;\n\n        for (int i = 0; i < n/2; i++) {\n            if (palindrome.charAt(i) != \'a\') {\n                sb.setCharAt(i, \'a\');\n                flag = false;\n                break;\n            }\n        }\n        \n        if(flag){\n            sb.setCharAt(n - 1, \'b\');\n        }\n\n        return sb.toString();\n    }\n}\n```
['Java']