Problem
Given a string s, rearrange its letters so that no two adjacent characters are the same. Return any valid arrangement, or "" if it is impossible.
Example 1
- Input
- "aab"
- Output
- "aba"
Example 2
- Input
- "aaab"
- Output
- ""
- Why
- three a's cannot be kept apart by one b
Example 3
- Input
- "vvvlo"
- Output
- "vlvov"
- Why
- "vovlv" is also fine
Constraints
1 <= s.length <= 500s holds only lowercase English letters.