Trains the technique from
LeetCode 1328Break a PalindromeThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
The word mirror reads the same forwards and backwards. Change exactly one of its letters to a different lowercase letter so that the word no longer reads the same both ways.
Return the smallest word that can result, ordered as a dictionary would, or an empty string when no single change can spoil it.
Example 1
The first letter is already as low as it goes, so the earliest letter that can be lowered is the second, and dropping it to an a leaves the word out of step with its reverse.
Example 2
Every letter is already an a, so nothing in the first half can be lowered, and raising the last letter to a b is the smallest change that spoils the mirror.
Example 3
Both letters are a, so the last one is raised to a b.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def break_palindrome(mirror: str) -> str:public String breakPalindrome(String mirror)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.