
g0201_0300.s0221_maximal_square.Solution.swift Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-all Show documentation
Show all versions of leetcode-in-all Show documentation
104 LeetCode algorithm problem solutions
// #Medium #Array #Dynamic_Programming #Matrix #Dynamic_Programming_I_Day_16
// #Big_O_Time_O(m*n)_Space_O(m*n) #2024_07_01_Time_350_ms_(93.48%)_Space_18.3_MB_(82.61%)
class Solution {
func maximalSquare(_ matrix: [[Character]]) -> Int {
guard matrix.count > 0 && matrix[0].count > 0 else { return 0 }
var square = Array(repeating: Array(repeating: 0, count: matrix[0].count), count: matrix.count)
var curMaxLen = 0
for i in 0..
© 2015 - 2025 Weber Informatics LLC | Privacy Policy