You are given a matrix of size m x n where each cell can contain either 1 or 0. You need to find the largest square submatrix that contains only 1's. The output should be the area of the largest square submatrix.
For example, given the following matrix:
1 0 1 1 1
1 0 1 1 1
1 1 1 1 1
1 0 0 1 0
The largest square submatrix that contains only 1's is:
1 1 1
1 1 1
1 1 1
So the output should be 9 since the area of the square is 3x3 = 9.
The time complexity of your algorithm should be O(mn).