Given a binary matrix of '0's and '1's, find the largest square containing only '1's and return its area.
Asked in the Coding round stage. This is LC 221 Maximal Square (the poster wrote the number in forum code). The expected approach is dynamic programming.
Implement maximal_square(matrix). matrix is a non-empty list of equal-length strings containing only '0' and '1'. Return an integer representing the area of the largest square containing only '1' cells. If no cell contains '1', return 0.
def maximal_square(matrix):