Reorganize String

Medium

📝 Description

Rearrange characters so no two adjacent are same

Input Format

A string

Output Format

Reorganized string or empty if impossible

Constraints

1 ≤ s.length ≤ 500

🔍 Sample Input

"aab"
            

✅ Sample Output

"aba"
            

Code Editor

Please login to run and submit code.

Shortcuts: Ctrl+Enter to submit, Ctrl+Shift+R to run