Problem Brief
Find Lexicographically Smallest String
FULLTIMEOA
See Amazon online assessment and hiring insights
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 Description
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
1Example 1
Input
s = "abbcd"
Output
"abcab"
Explanation
🍊