Company: Deutsche_Bank_26nov
Difficulty: medium
Symmetric Grid Description You are presented with a two-dimensional grid of size N x M (N rows and M columns). Each cell in the grid is either black ( B ) or white ( W ). A row or column is considered symmetric if it reads the same forwards as it does backward. For example, the row BWWBWWB is symmetric, whereas WBWB is not. The same symmetry criterion applies to columns: a column is read from the top row to the bottom row. In one move, you can change the color of a single cell to the opposite color. Your task is to determine the minimum number of moves required to make every row and every column of the grid symmetric at the same time. Implement the function: int solution(vector<string> &grid) // C++ public int solution(String[] grid) // Java, inside class Solution def solution(grid) # Python grid holds N strings, all of length M; each string is a single row of the grid, listed from top to bottom. The function returns the minimum number of moves. Input Format A single line con