This video is part of the Heap section under GFG SDE Sheet.
Given a string S with repeated characters. The task is to rearrange characters in a string such that no two adjacent characters are the same.
Note: The string has only lowercase English alphabets and it can have multiple solutions. Return any one of them.
Example 1:
Input : str = "geeksforgeeks" Output: 1 Explanation: All the repeated characters of the given string can be rearranged so that no adjacent characters in the string is equal. Any correct rearrangement will show a output of 1.
Do check out:-
Problem: https://www.geeksforgeeks.org/problems/rearrange-characters4649/1
SDE Sheet Link: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/
Article Link: https://www.geeksforgeeks.org/rearrange-characters-string-no-two-adjacent/