221 Maximal Square
https://leetcode.com/problems/maximal-square/
solution
2d动态规划, dp[i][j]以matrix[i-1][j-1]为右下底的全是1的最大square的边长
因为涉及到前面的状态,i-1和j-1来简化初始化过程
Space can be optimized as we don't need to keep the whole dp grid as we progress down the rows in matrix
时间复杂度:O(mn) 空间复杂度:OnmN)
follow up
Last updated