Practice Count Submatrices With Equal Frequency of X and Y
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
Given a grid containing X, Y, and ., count rectangular submatrices that contain grid[0][0], contain at least one X, and have equal numbers of X and Y cells.
Source: Count Submatrices With Equal Frequency of X and Y on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
grid = [["X","Y","."],["Y",".","."]]
Output
3
# Example 2
Input
grid = [["X","X"],["X","Y"]]
Output
0
# Example 3
Input
grid = [[".","."],[".","."]]
Output
0
Constraints
1 <= grid.length, grid[i].length <= 1000
grid[i][j] is either 'X', 'Y', or '.'.
Related LeetCode Problems
Practice more problems similar to Count Submatrices With Equal Frequency of X and Y.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.