Problem Brief
Next Greater Perfect String
FULLTIMEOA
See Amazon online assessment and hiring insights
SDE II
Amazon is creating a system which always returns perfect strings. A perfect string is a string in which no 2 adjacent characters are same. You will be given a starting string which can be perfect or cannot be. You have to return the lexicographically next smallest perfect string greater than the current string lexicographically.
1Example 1
Input
s = "abzzzcd"
Output
"acababa"
Explanation
:)
2Example 2
Input
s = "zzab"
Output
"-1"
Explanation
Because there will be no perfect lexigraphically greater string than zzab.