Break a Palindrome

A palindrome reads the same forwards and backwards, like "mom". Modify a palindrome by changing exactly one character to another character within the ASCII range [a-z]. The goal is to ensure the new string fulfills the following criteria:

  • It is not a palindrome.
  • It is alphabetically lower than the original palindrome.
  • It is the smallest possible string alphabetically that can be obtained by changing just one character.

Return the new string, or "IMPOSSIBLE" if it is not feasible to create such a string.

Function Description

Complete the function breakPalindrome in the editor with the following parameter(s):

  • string palindromeStr: the input string

Returns

string: the resulting string, or IMPOSSIBLE if one cannot be formed

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: