human
Can you provide a code to count subarrays made up of single and the other steps required given the following:
Count subarrays made up of single | Function to count of subarrays made up of single digit integers only.
Stores count of subarrays.
Stores the count of consecutive single digit numbers in the array.
Traverse the array.
Increment size of block by 1.
Increment res by count.
Assign count = 0.
Driver Code.
Given array.
Size of the array"
Solution in Python:
assistant
#Here is code to count subarrays made up of single and the other steps required.
 def singleDigitSubarrayCount ( arr , N ) :
	res = 0
	count = 0
	for i in range ( N ) :
		if ( arr [ i ] <= 9 ) :
			count += 1
			res += count
		else :
			count = 0
	print ( res )
if __name__ == ' _ _ main _ _ ' :
	arr = [ 0 , 1 , 14 , 2 , 5 ]
	N = len ( arr )
	singleDigitSubarrayCount ( arr , N )