#767
Reorganize String
specialist · 760 · lc medium +31 · verified · 56.9% accepted · 9,193 likes · top 52%
Description
Given a string s, produce a rearrangement of its characters such that no two adjacent characters are equal. Return any valid rearrangement, or "" if none exists.
Example 1:
Input: s = "aab"
Output: "aba"
Example 2:
Input: s = "aaab"
Output: ""
Code
1
2
3