You are required to implement a function that calculates the minimum number of flips needed to change all squares in a given grid to white. The grid consists of squares that can either be black ('B') or white ('W'). A flip changes a square from black to white or vice versa. Your implementation should efficiently determine the minimum number of flips required based on the provided grid configuration.
Input Requirements
The function should accept three parameters:
m (int): The number of rows in the grid (1 <= m <= 100).
n (int): The number of columns in the grid (1 <= n <= 100).
grid (List[List[str]]): A 2D list representing the grid, where each element is either 'B' or 'W'.
Output Requirements
The function should return an integer: the minimum number of flips needed to turn all squares to white.
Implementation Details
The function must be named minimum_flips_to_white.
Please ensure that the function correctly handles edge cases, such as when the grid is already all white.
Avoid using external libraries; rely solely on Python's built-in capabilities.
File Structure
Your solution must be written in a file located at /app/solution.py with the following function signature:
python
def minimum_flips_to_white(m, n, grid):
# Implementation here
Example
For example, given the input:
python
m = 3
n = 3
grid = [
["W", "B", "W"],
["B", "B", "W"],
["W", "W", "W"]
]
The function call:
python
minimum_flips_to_white(m, n, grid)
Should return 3, as three flips are required to turn all black squares to white.