Skip to the content.

Asked by Flexport

Question

Given a string s, rearrange the characters so that any two adjacent characters are not the same. If this is not possible, return null.

For example, if s = yyz then return yzy. If s = yyy then return null.