Question bank › Strings
Dsa Strings Easy

Unique Char Reorder

Write a program that takes a string as input and checks if it can be rearranged so that no two adjacent characters are the same. If possible, output the rearranged string; if not, return 'Not Possible'. Note that strings may contain uppercase and lowercase letters and spaces. Input Format: A single line of text containing the input string. Output Format: A rearranged string with no two adjacent characters being the same, or 'Not Possible'. Example: Input: aaabb Output: baaba

Key concepts

stringsreorderingunique

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.