Count of Ks in the Array for a given range of indices after array updates for Q queries | ''Function to perform all the queries ; ''Stores the count of 0s ; ''Count the number of 0s for  query of type 1 ; '' Update the array element for  query of type 2 ; ''Driver Code
def performQueries ( n , q , k , arr , query ) : NEW_LINE INDENT for i in range ( 1 , q + 1 , 1 ) : NEW_LINE count = 0 NEW_LINE if ( query [ i - 1 ] [ 0 ] == 1 ) : NEW_LINE DEDENT for j in range ( query [ i - 1 ] [ 1 ] , query [ i - 1 ] [ 2 ] + 1 , 1 ) : NEW_LINE INDENT if ( arr [ j ] == k ) : NEW_LINE DEDENT count += 1 NEW_LINE INDENT print ( count ) NEW_LINE else : NEW_LINE DEDENT arr [ query [ i - 1 ] [ 1 ] ] = query [ i - 1 ] [ 2 ] NEW_LINE if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 9 , 5 , 7 , 6 , 9 , 0 , 0 , 0 , 0 , 5 , 6 , 7 , 3 , 9 , 0 , 7 , 0 , 9 , 0 ] NEW_LINE Q = 5 NEW_LINE INDENT query = [ [ 1 , 5 , 14 ] , [ 2 , 6 , 1 ] , [ 1 , 0 , 8 ] , [ 2 , 13 , 0 ] , [ 1 , 6 , 18 ] ] NEW_LINE DEDENT N = len ( arr ) NEW_LINE DEDENT K = 0 NEW_LINE INDENT performQueries ( N , Q , K , arr , query ) NEW_LINE DEDENT