Find Min Num Moves
Learn this problemProblem statement
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, a row "BWWBWWB" 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.
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.
Function
findMinNumMoves(grid: String[]) → intExamples
Example 1
grid = ["BBWWB", "WWWBW", "BWWWW"]return = 3Example 2
grid = ["BBBB", "WWWW", "BBWB", "WWWW"]return = 7Example 3
grid = ["BWB", "WBB", "WBW"]return = 4More Microsoft problems
- Maximum Pipeline ThroughputOA · Seen Jul 2026
- Maximum Strong Team SubarrayOA · Seen Jul 2026
- Minimum Cost K-Capable ModelsOA · Seen Jul 2026
- Alphabetically Smallest PalindromeOA · Seen Jul 2026
- Maximum Reward PointsOA · Seen Jul 2026
- Maximum Strength of Every NeuronOA · Seen Jul 2026
- Neural Network Subnetwork StrengthOA · Seen Jul 2026
- XOR MultiplicationOA · Seen Jul 2026