Python brute force
Just using how fast Python is with string operations. Got accepted in 28 ms.\n\nTry replacing each character (except a middle one) with \'a\' if it\'s not \'a\'
Just using how fast Python is with string operations. Got accepted in 28 ms.\n\nTry replacing each character (except a middle one) with `\'a\'` if it\'s not `\'a`\' already, and with `\'b\'` otherwise. Take the minimum such modified string, default to empty string.\n```\ndef breakPalindrome(self, p):\n    return min((p[:i] + \'ba\'[c > \'a\'] + p[i+1:]\n                for i, c in enumerate(p)\n                if 2*i != len(p)-1),\n               default=\'\')\n```
[]