Reorganize String

Given a string s, rearrange its characters so that no two adjacent characters are the same. Return any possible rearrangement or an empty string if not possible.

Constraints

  • 1 <= s.length <= 500
  • s consists of lowercase English letters.
Saving… · 3 lines
class Solution:
def reorganize_string(self, s: str) -> str:
pass
Console

Click Run to execute sample tests.