Skip to main content

Posts

Showing posts with the label Query And Matrix

Query And Matrix

  Query And Matrix Send Feedback You are given a binary matrix with ‘M’ rows and ‘N’ columns initially consisting of all 0s. 'Q' queries follow. The queries can be of 4 types: Query 1: 1 R index Query 2: 1 C index Query 3: 2 R index Query 4: 2 C index In each query, the first input is the type of the query, the second input is whether we have to consider the row ('R') or the column ('C') and the third input is the index of the row/column. For each type 1 query, we need to flip the elements of the row/column having the given index. For each type 2 query, we have to output the number of zeros present in the row/column having the given index. Note: Note that the matrix is a binary matrix, meaning that it only contains either 0 or 1. Example : Given M = 3, N = 3, Queries : 1R1, 1R2, 2C1 So, in the above example the change in the matrix would look like this: Next query 2C1 will return the count of the number of zeroes in the 1st column: 1 Input Format: The f...