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:
2Explanation:
After applying all operations: [3,2] increments a 3x2 region, [2,4] increments a 2x4 region, and [1,3] increments a 1x3 region. Their overlap is a 1x2 region, so 2 cells receive all 3 increments and share the maximum value.
Constraints
- •
1 ≤ m, n ≤ 4 * 10^4 - •
0 ≤ ops.length ≤ 10^4