human
Number of sub | Function to return the count of required sub - strings.
Left and right counters for characters on both sides of sub - string window.
Left and right pointer on both sides of sub - string window.
Initialize the frequency.
Result and length of string.
Initialize the left pointer.
Initialize the right pointer.
Traverse all the window sub - strings.
Counting the characters on left side of the sub - string window.
Counting the characters on right side of the sub - string window.
Add the possible sub - strings on both sides to result.
Setting the frequency for next sub - string window.
Reset the left and right counters.
Driver code"
Solution in Python:
assistant
#Here is code to number of sub and the other steps required.
 def countSubString ( s , c , k ) :
	leftCount = 0
	rightCount = 0
	left = 0
	right = 0
	freq = 0
	result = 0
	len1 = len ( s )
	while ( s [ left ] != c and left < len1 ) :
		left += 1
		leftCount += 1
	right = left + 1
	while ( freq != ( k - 1 ) and ( right - 1 ) < len1 ) :
		if ( s [ right ] == c ) :
			freq += 1
		right += 1
	while ( left < len1 and ( right - 1 ) < len1 ) :
		while ( s [ left ] != c and left < len1 ) :
			left += 1
			leftCount += 1
		while ( right < len1 and s [ right ] != c ) :
			if ( s [ right ] == c ) :
				freq += 1
			right += 1
			rightCount += 1
		result = ( result + ( leftCount + 1 ) * ( rightCount + 1 ) )
		freq = k - 1
		leftCount = 0
		rightCount = 0
		left += 1
		right += 1
	return result
if __name__ == ' _ _ main _ _ ' :
	s = " abada "
	c = ' a '
	k = 2
	print ( countSubString ( s , c , k ) )