Practice Make a Square with the Same Color
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given a 2D matrix grid of size 3 x 3 consisting only of characters 'B' and 'W'. Character 'W' represents the white color, and character 'B' represents the black color. Your task is to change the color of at most one cell so that the matrix has a 2 x 2 square where all cells are of the same color. Return true if it is possible to create a 2 x 2 square of the same color, otherwise, return false.
Source: Make a Square with the Same Color on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
grid = [["B","W","B"],["B","W","W"],["B","W","B"]]
true
# Example 2
grid = [["B","W","B"],["W","B","W"],["B","W","B"]]
false
# Example 3
grid = [["B","W","B"],["B","W","W"],["B","W","W"]]
true
Constraints
Related LeetCode Problems
Practice more problems similar to Make a Square with the Same Color.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.