human
Number of indexes with equal elements in given range | function that answers every query in O ( r - l ).
traverse from l to r and count the required indexes.
Driver Code.
1 - st query.
2 nd query"
Solution in Python:

Write me a code to number of indexes with equal elements in given range and the other steps required?
assistant
#Here is code to number of indexes with equal elements in given range and the other steps required.
 def answer_query ( a , n , l , r ) :
	count = 0
	for i in range ( l , r ) :
		if ( a [ i ] == a [ i + 1 ] ) :
			count += 1
	return count
a = [ 1 , 2 , 2 , 2 , 3 , 3 , 4 , 4 , 4 ]
n = len ( a )
L = 1
R = 8
print ( answer_query ( a , n , L , R ) )
L = 0
R = 4
print ( answer_query ( a , n , L , R ) )