Given two strings, we need to take the character which has the maximum occurrence in the first string and then we have to check if that particular character is present in the second string the same number of times as it is present in the first string.
Input : s1 = "sssgeek", s2 = "geeksss" Output : Yes Max occurring character in s1 is 's'. It occurs same number of times in s2. Input : geekyarticle gfggfggfg Output : No
Store counts of characters in first string and find the maximum count. Now traverse through the second string and check if the maximum occurring character occurs same number of times or not.
Below program to illustrate the above problem
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check if frequency of character in one string is a factor or multiple of frequency of same character in other string
- Lengths of maximized partitions of a string such that each character of the string appears in one substring
- Maximized partitions of a string such that each character of the string appears in one substring
- Longest subsequence where every character appears at-least k times
- Count substrings with each character occurring at most k times
- Map every character of one string to another such that all occurrences are mapped to the same character
- Sub-strings that start and end with one character and have at least one other
- Remove characters from string that appears strictly less than K times
- Remove characters from a String that appears exactly K times
- NFA to accept strings that has atleast one character occurring in a multiple of 3
- Replace every character of string by character whose ASCII value is K times more than it
- Check if two strings can be made equal by swapping one character among each other
- Find the only element that appears b times
- Count all elements in the array which appears at least K times after their first occurrence
- Maximum number of times str1 appears as a non-overlapping substring in str2
- Count number of times each Edge appears in all possible paths of a given Tree
- Return maximum occurring character in an input string
- Maximum occurring character in an input string | Set-2
- Shortest distance to every other character from given character
- Maximum occurring character in a linked list
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.