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
- Longest subsequence where every character appears at-least k times
- Count substrings with each character occurring at most k times
- Remove characters from string that appears strictly less than K times
- Maximum occurring character in an input string | Set-2
- Return maximum occurring character in an input string
- Replace every character of string by character whose ASCII value is K times more than it
- Encrypt a string by repeating i-th character i times
- Print the string after the specified character has occurred given no. of times
- Decrypt a string encrypted by repeating i-th character i times
- Find the only element that appears b times
- Count all elements in the array which appears at least K times after their first occurrence
- Check if frequency of character in one string is a factor or multiple of frequency of same character in other string
- Maximum number of times str1 appears as a non-overlapping substring in str2
- Maximum occurring character in a linked list
- Check if both halves of the string have at least one different character
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.