Tap here to switch tabs
Problem
Submissions

Problem: Range Addition II

med
30 min
Try to solve the Range Addition II problem.

Statement

You are given an m $ imes$ n integer matrix initialized with all 00s, and a 22D array of integers ops where each operation is represented as ops[i] =[ai,bi]= [a_i, b_i].

For each operation ops[i], all cells in the matrix with row index rr and column index cc satisfying 0≤r<ai0 \leq r < a_i and 0≤c<bi0 \leq c < b_i are incremented by 11.

Return the number of cells in the matrix that contain the maximum value after executing all operations in ops.

Constraints:

  • 1≤1 \leq m, n ≤4imes104\leq 4 imes 10^4

  • 0≤0 \leq ops.length ≤104\leq 10^4

  • ops[i].length =2= 2

  • 1≤1 \leq a_i ≤\leq m

  • 1≤1 \leq b_i ≤\leq n

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Range Addition II

med
30 min
Try to solve the Range Addition II problem.

Statement

You are given an m $ imes$ n integer matrix initialized with all 00s, and a 22D array of integers ops where each operation is represented as ops[i] =[ai,bi]= [a_i, b_i].

For each operation ops[i], all cells in the matrix with row index rr and column index cc satisfying 0≤r<ai0 \leq r < a_i and 0≤c<bi0 \leq c < b_i are incremented by 11.

Return the number of cells in the matrix that contain the maximum value after executing all operations in ops.

Constraints:

  • 1≤1 \leq m, n ≤4imes104\leq 4 imes 10^4

  • 0≤0 \leq ops.length ≤104\leq 10^4

  • ops[i].length =2= 2

  • 1≤1 \leq a_i ≤\leq m

  • 1≤1 \leq b_i ≤\leq n