All Downloads are FREE. Search and download functionalities are using the official Maven repository.

g0201_0300.s0221_maximal_square.Solution.swift Maven / Gradle / Ivy

There is a newer version: 1.8
Show newest version
// #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