Given a string str, the task is to find the count of all the sub-strings of length four whose characters can be rearranged to form the word “clap”.
Input: str = “clapc”
“clap” and “lapc” are the required sub-strings
Input: str = “abcd”
Approach: For every sub-string of length four, count the occurrences of the characters from the word “clap”. If every character has the occurrence exactly one in the sub-string then increment the count. Print the count in the end.
Below is the implementation of the above approach:
- Check if characters of a given string can be rearranged to form a palindrome
- Count substrings with same first and last characters
- Recursive solution to count substrings with same first and last characters
- Count number of substrings with exactly k distinct characters
- Count distinct substrings that contain some characters at most k times
- Java program to count the characters in each word in a given sentence
- Check if a string can be rearranged to form special palindrome
- Find number of substrings of length k whose sum of ASCII value of characters is divisible by k
- Find largest word in dictionary by deleting some characters of given string
- Find the count of substrings in alphabetic order
- Queries for frequencies of characters in substrings
- Possibility of a word from a given set of characters
- Next word that does not contain a palindrome and has characters from first k
- Arrangement of the characters of a word such that all vowels are at odd places
- Print list items containing all characters of a given word
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.