Dsa
Strings
Medium
String Rearranger
Given a string, return true if it is possible to rearrange the characters such that no two adjacent characters are the same. If rearrangement is not possible, return false.
Example:
Input:
'aabb'
Output:
True
Input:
'aabbcc'
Output:
True
Input:
'aaab'
Output:
False
Key concepts
stringsrearrangementvalidation
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now