Tap here to switch tabs
Problem
Submissions

Problem: Reorganize String

Reorganize String asks you to rearrange every character in a given string so identical characters are never adjacent, returning any valid arrangement or an empty string if none exists.

Statement

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.

Constraints:

  • 1≤1\leq str.length ≤500\leq500
  • Input string consists of lowercase English letters.
⋮
Tap here to switch tabs
Problem
Submissions

Problem: Reorganize String

Reorganize String asks you to rearrange every character in a given string so identical characters are never adjacent, returning any valid arrangement or an empty string if none exists.

Statement

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.

Constraints:

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