Largest square of ones
Your task
Given an m x n binary matrix whose entries are 0 or 1, find the largest square containing only 1s and return its area. If the matrix contains no 1s, return 0. The matrix has at least one cell and dimensions up to 300x300.
Examples
maximal_square(matrix: list[list[int]]) -> intExample 1
Input
maximal_square([[1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0]])Output
4