Tap here to switch tabs
Problem
Submissions

Problem: Max Side Length of a Square With Sum at Most Threshold

Try to solve the Maximum Side Length of a Square with Sum Less than or Equal to Threshold problem.

Statement

Given an m by n matrix mat and an integer threshold, return the maximum side length of a square subgrid whose sum of elements is less than or equal to threshold. If no such square exists, return 00.

Constraints:

  • m == mat.length

  • n == mat[i].length

  • 1≤1 \leq m, n ≤300\leq 300

  • 0≤0 \leq mat[i][j] ≤104\leq 10^4

  • 0≤0 \leq threshold ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Max Side Length of a Square With Sum at Most Threshold

Try to solve the Maximum Side Length of a Square with Sum Less than or Equal to Threshold problem.

Statement

Given an m by n matrix mat and an integer threshold, return the maximum side length of a square subgrid whose sum of elements is less than or equal to threshold. If no such square exists, return 00.

Constraints:

  • m == mat.length

  • n == mat[i].length

  • 1≤1 \leq m, n ≤300\leq 300

  • 0≤0 \leq mat[i][j] ≤104\leq 10^4

  • 0≤0 \leq threshold ≤105\leq 10^5