✅C++ solution [beats 100% in time] | ☑️ Python solution | [greedy solution]
Please upvote to motivate me to write more solutions\n\n# Code [C++ beats 100% & 70%]\n\nclass Solution {\npublic:\n    string breakPalindrome(string palindrome
*Please upvote to motivate me to write more solutions*\n\n# Code [C++ beats 100% & 70%]\n```\nclass Solution {\npublic:\n    string breakPalindrome(string palindrome) {\n        \n        for (int i=0; i<palindrome.length()/2; i++) {\n            if (palindrome[i] != \'a\') {\n                palindrome[i] = \'a\';\n                return palindrome;\n            }\n        }\n\n        palindrome[palindrome.length()-1]=\'b\';\n        return palindrome.length() > 1 ? palindrome : "";\n    }\n};\n```\n\n# Code [Python beats 21% & 61%]\n\n```\nclass Solution:\n    def breakPalindrome(self, palindrome: str) -> str:\n        palindrome=list(palindrome)\n        for i in range(int(len(palindrome)/2)):\n            if palindrome[i]!="a":\n                palindrome[i]=\'a\'\n                return "".join(palindrome)\n        palindrome[len(palindrome)-1] = \'b\'\n        if len(palindrome)>1:\n            return "".join(palindrome)\n        else:\n            return ""\n```
['Greedy', 'Python', 'C++', 'Python3']