human
Count of substrings containing only the given character | Function that finds the count of substrings containing only character C in the S.
To store total count of substrings.
To store count of consecutive C 's.
Loop through the string.
Increase the consecutive count of C 's.
Add count of sub - strings from consecutive strings.
Reset the consecutive count of C 's.
Add count of sub - strings from consecutive strings.
Print the count of sub - strings containing only C.
Driver Code"
Solution in Python:
 ... Give me a code to count of substrings containing only the given character and the other steps required?
assistant
#Here is code to count of substrings containing only the given character and the other steps required.
 def countSubString ( S , C ) :
	count = 0
	conCount = 0
	for ch in S :
		if ( ch == C ) :
			conCount += 1
		else :
			count += ( ( conCount * ( conCount + 1 ) ) // 2 )
			conCount = 0
	count += ( ( conCount * ( conCount + 1 ) ) // 2 )
	print ( count )
if __name__ == ' _ _ main _ _ ' :
	S = " geeksforgeeks "
	C = ' e '
	countSubString ( S , C )