Company: Media_Net__SDE_17nov

Difficulty: medium

Problem Statement

Problem Description You are given two N x N matrices, A and B, where every entry is either 0 or 1. On matrix A, you may repeatedly perform the following move: pick any 2x2 contiguous block within A and flip every entry inside it, that is, replace each A[i][j] in that block with A[i][j] XOR 1. Determine whether some sequence of such moves can turn A into B. Return 1 if it can be done, and 0 otherwise. Examples Example 1 Input A = [[1, 1], [1, 1]] B = [[0, 0], [0, 0]] Output: 1 Explanation: Only a single 2x2 block can be chosen here, and flipping it turns A directly into B. Example 2 Input A = [[1, 1, 0], [0, 0, 0], [1, 1, 1]] B = [[0, 0, 0], [0, 0, 0], [0, 0, 1]] Output: 1 Explanation: Flipping the top-left 2x2 block first changes A to [[0, 0, 0], [1, 1, 0], [1, 1, 1]]. Flipping the bottom-left 2x2 block next turns A into B. Constraints 2 <= N <= 10^3 (where N is the dimension of matrices A and B) 0 <= A[i][j], B[i][j] <= 1

More Media_Net__SDE_17nov OA questionsInterview experiences