Panda Guru LogoPanda
Guru

AMAZON OA

Round 1

Questions: Currently, the utility generates only special strings. A string is special if there are no matching adjacent characters. Given a string s of length n, generate a special string of length n that is lexicographically greater than s. If multiple such special strings exist, return the smallest string among them.

A string a is lexicographically smaller than a string b if and only if one of the following holds:

Important Considerations:

The lexicographically smallest special string that is greater than "abbd" is "abca".

Function Description: Complete the function getSpecialString in the editor below.

getSpecialString has the following parameter:

Returns:

Constraints:

Sample Input:

abccde

Sample Output:

abcdab

Explanation: s = "abccde" Some of the special strings that are lexicographically greater than s are "abcdde", "abcdab", "abcdbc".

Sample Case 1: Sample Input For Custom Testing:

zzab

Sample Output:

-1

Explanation: s = "zzab" There is no special string of length 4 that is lexicographically greater than s.

Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.