Rearrange characters so that no two adjacent characters are the same.
Unlock detailed company stats for this questionUpgrade
Given a string of repeated lowercase English characters (1 <= len(s) <= 10^5), rearrange the characters so that no two adjacent characters are equal. Example: "aabbbcdeefg" -> a possible output is "ababcdegfeb"; any valid arrangement works.
Max-heap greedy approach.
Format · Technical round.
Also asked as · Rearrange a string so that no two adjacent characters are equal.
Community answers
No answers contributed by the community yet.
Related questions
Find the minimum changes so no two adjacent engineers in a circle choose the same option.Rearrange characters so identical ones are at least k positions apart.Related courses

Course

Course
Course
