Problem · String
Find Lexicographically Smallest String
Learn this problemProblem statement
Given a character string, find the lexicographically smallest string of the same length that is greater than the original string, with the condition that no two adjacent characters are the same. If no such string exists, return -1.
The string only contains letters, with 'a' being the smallest and 'z' being the largest.
Function
findLexicographicallySmallestString(s: String) → String
Complete the function findLexicographicallySmallestString in the editor.
findLexicographicallySmallestString has the following parameter:
String s: the original string
Returns
String: the lexicographically smallest string that meets the condition or "-1" if no such string exists
Examples
Example 1
s = "abbcd"return = "abcab"🍊