Jeff is working on a text compression algorithm. He has to compress large text documents into smaller text documents where he keeps a dictionary of compressed words and replaces those words with a small text-based sequence calculated by an algorithm. It's going well until he finds two special use cases.
1.) Some strings are repeating sequences of the same character such as "zzz" and "ooo".
2.) Some strings are the same from start and end but the middle character is different, such as "oho", "aha".
He needs to find a way to compress these strings into a smaller string, but before that, he needs to find out how many of these special strings are present in the text.
There are two parameters given, an integer and a string. You have to find the total number of sub-strings that match the two use cases that we discussed above in the provided string in the parameter.
Write a function
solve that have the following parameter(s):
1.) s = a string
2.) length = an integer
s = "abaabaab"
length = 8 Output:
The function will return,
The length of a string will be:
The total number of the sub-string will be: