Reorganize String

Try to solve the Reorganize String problem.


Given a string, str, rearrange it so that any two adjacent characters are not the same. If such a reorganization of the characters is possible, output any possible valid arrangement. Otherwise, return an empty string.


  • 11\leq str.length 500\leq500
  • Input string consists of lowercase English letters.


Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy