Solution: Reorganize String
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:
-
str.length
- Input string consists of lowercase English letters.
Access this course and 1400+ top-rated courses and projects.