I am trying to find the length of the longest consecutive character('!') in a string.
For example, input:
!!!!Hello!!
Output:
4
I am trying to solve this problem with recursion and this is my approach:
unsigned int length_of_longest_consecutive_dquotes(const char line[], int start)
{
if (line[start] != '\0') {
if (line[start] == '!') {
return length_of_longest_consecutive_mark(line,start+1) + 1;
}
else
return length_of_shortest_consecutive_mark(line,start+1);
}
return 0;
}
Where Start = 0; I am not able to figure out what shall I implement in the length_of_shortest_consecutive_dquotes(line,start) function. Please suggest me some better algorithm for implementing it. Thanks!