Dsa
Sliding Window
Medium
Rearrange Substring for Unique Characters
Write a program to check if it is possible to rearrange any substring of a given string such that it contains all unique characters. Return the longest such substring or "Not possible" if no valid substring exists.
Input format:
The first line contains a string.
Output format:
Print the longest substring with all unique characters or "Not possible".
Example:
Input:
aabbccdd
Output:
aa
Key concepts
sliding_windowstring_manipulation
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