Description
You are given an m x n matrix M initialized with all 0s and an array of operations ops. Each operation [ai, bi] increments all elements in M[0..ai-1][0..bi-1] by 1. Return the count of maximum integers in the matrix after all operations.
Examples
Input:
m = 3, n = 3, ops = [[2,2],[3,3]]Output:
4Explanation:
After ops, max is 2 in a 2x2 region.
Input:
m = 3, n = 3, ops = [[1]]Output:
1Explanation:
After one operation on a 1x1 region, only the top-left cell has the maximum value.
Input:
m = 4, n = 5, ops = [[3,2],[2,4],[1,3]]Output:
1Explanation:
After applying all operations: [3,2] increments a 3x2 region, [2,4] increments a 2x4 region, and [1,3] increments a 1x3 region. The cell at M[0][0] is the only cell incremented by all 3 operations, giving it the maximum value of 3. Therefore, the count of cells with maximum value is 1.
Constraints
- •
1 ≤ m, n ≤ 4 * 10^4 - •
0 ≤ ops.length ≤ 10^4