
Rearrange String Problem Statement
Given a string ‘S’, your task is to rearrange its characters so that no two adjacent characters are the same. If it's possible, return any such arrangement, otherwise return “not possible”.
Example:
Input:
S = "qaacde"
Output:
"qacade"
Explanation:
In the string "qaacde", originally there are two same adjacent characters. One possible rearrangement where no two adjacent characters are the same is "qacade".
Input:
T
S1
S2
…
ST
Output:
"Yes" if rearrangement is possible, otherwise "No" for each test case.
Constraints:
- 1 <= T <= 10
- 0 <= |S| <= 105
- Time Limit: 1 second.
Note:
No need to print anything; implementation of the function is sufficient.

AnswerBot
13d

Given a string, rearrange its characters so that no two adjacent characters are the same. Return 'Yes' if possible, 'No' otherwise.
Iterate through the string and count the frequency of each character
U...read more

Help your peers!
Add answer anonymously...
Top PayPal Full Stack Developer interview questions & answers
Popular interview questions of Full Stack Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app