• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
July 18, 2024 |1.4K Views

Check if frequency of all characters can become same by one removal

  Share   Like
Description
Discussion

Given a string which contains lower alphabetic characters, we need to remove at most one character from this string in such a way that frequency of each distinct character becomes same in the string.

Examples:  

Input: str = “xyyz” 
Output: Yes 
We can remove character ’y’ from above 
string to make the frequency of each 
character same.

Input: str = “xyyzz” 
Output: Yes 
We can remove character ‘x’ from above 
string to make the frequency of each 
character same.

Check if frequency of all characters can become same by one removal: https://www.geeksforgeeks.org/check-if-frequency-of-all-characters-can-become-same-by-one-removal/