Amazon SDE-1 Onsite
Anonymous User
3612

Given a string with repeated characters, the task is to rearrange characters in a string so that no two adjacent characters are same.

Asked interviewer if the characters are in lower or upper case.

Gave two approaches.
One to fill all the even positions of the result string first, with the highest frequency character.
Second was using priority Queue.

Interviewer seemed satisfied. Asked me to code it.

Follow up questions included, inbuilt working of priority queue, default heap representation etc.

Comments (5)