Company: Deutsche_Bank_26nov
Difficulty: medium
Symmetric Grid Problem Symmetric Grid Problem Description You are presented with a two-dimensional grid of size N × 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, a row "BWBWBWB" is symmetric whereas "WBWB" isn't. The same symmetry criterion applies to columns. In one move, you can change the color in a single cell to the opposite. Your task is to determine the minimum number of moves required to make every row and column in the grid symmetric. Write a function: class Solution { public int solution(String[] grid); } or in C++: int solution(vector<string> &grid); that, given an array grid consisting of N strings, all of length M (each string is a single row of the grid), returns the minimum number of moves required to make all rows and columns symmetric. Examples Example 1: Input: grid = ["BBWWB", "WWWWBW", "BWWWW"] Output: 3