Practice Maximum Side Length of a Square with Sum Less than or Equal to Threshold
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Medium#1292
LeetCode ProblemMaximum Side Length of a Square with Sum Less than or Equal to Threshold
Problem Statement
Given a m x n matrix mat and an integer threshold, return the maximum side-length of a square with a sum less than or equal to threshold or return 0 if there is no such square.
Source: Maximum Side Length of a Square with Sum Less than or Equal to Threshold on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
mat = [[1,1,3,2,4,3,2],[1,1,3,2,4,3,2],[1,1,3,2,4,3,2]], threshold = 4
Output
2
# Example 2
Input
mat = [[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2]], threshold = 1
Output
0
Constraints
m == mat.length
n == mat[i].length
1 <= m, n <= 300
0 <= mat[i][j] <= 10^4
0 <= threshold <= 10^5
Related LeetCode Problems
Practice more problems similar to Maximum Side Length of a Square with Sum Less than or Equal to Threshold.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.