human
I am working on the file "Python/leetcode/medium/String-Problems-1.ipynb".
The first task is:
P2. Maximal Square Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.
```
Example:
Input: 
1 0 1 0 0
1 0 1 1 1
1 1 1 1 1
1 0 0 1 0
Output: 4
```
Can you write Python code for it?
 Give me a Python code to find the largest square containing only 1's and return its area?
assistant
#Here is Python code to find the largest square containing only 1's and return its area.

def find_largest_square(matrix) -> int:
    if matrix == []:
        return 0
    
    size = (len(matrix), len(matrix[0]))
    max_sq_size = size[0] if size[0] < size[1] else size[1]
    
    def get_square_size(pos):
        sq_size = 1
        while sq_size <= max_sq_size and (pos[0] + sq_size) <= size[0] and (pos[1] + sq_size) <= size[1]:
            for i in range(pos[0], pos[0] + sq_size):
                for j in range(pos[1], pos[1] + sq_size):
                    if matrix[i][j] == "0":
                        return (sq_size - 1) * (sq_size - 1)
            
            sq_size += 1
        
        return (sq_size - 1) * (sq_size - 1)
    
    max_size = 0
    for i in range(0, size[0]):
        for j in range(0, size[1]):
            if matrix[i][j] == "1":
                curr_size = get_square_size((i, j))
                if  curr_size > max_size:
                    max_size = curr_size 
    
    return max_size

print(find_largest_square([["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]))
print(find_largest_square([]))
print(find_largest_square([["1","0"],["1","0"]]))
print(find_largest_square([["1"]]))