Get Special String
Problem Overview
- Generate a special string (no two adjacent characters match) of the same length as s that is lexicographically greater than s; if multiple exist, return the smallest; if none, return "-1".
- Input: lowercase string s (1 ≤ |s| ≤ 10^6); Output: the special string or "-1"; no wrap-around after 'z'.
- Real-world context: text generation utility ensuring no adjacent repeats.
- From Amazon interviews; a coding interview problem and interview question.
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:
