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
- Count number of substrings with exactly k distinct characters
- Count of Substrings that can be formed without using the given list of Characters
- Count distinct substrings that contain some characters at most k times
- Recursive solution to count substrings with same first and last characters
- Count of all unique substrings with non-repeating characters
- Count number of substrings of a string consisting of same characters
- 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 to find the count of vowels in the substrings of the given string
- Find distinct characters in distinct substrings of a string
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.