def findLargestSquare(board):
col = len(board[0])
row = len(board)
mx=0
dp=[[0]*col for i in range(row)]
for i in range(1,row):
for j in range(1,col):
if board[i][j] == 'O':
dp[i][j] = min(dp[i-1][j-1],dp[i-1][j],dp[i][j-1])+1
if mx < dp[i][j]: mx=dp[i][j]
return mx**2
testBoard = [['X','O','O','O','X'],['X','O','O','O','O'],['X','X','O','O','O'],['X','X','O','O','O'],['X','X','X','X','X']]
print(findLargestSquare(testBoard))
'알고리즘 문제' 카테고리의 다른 글
Programmers Level 4 공항 건설하기 (0) | 2018.01.28 |
---|---|
Programmers Level 4 최고의 집합 (0) | 2018.01.28 |
Programmers Level 4 숫자의 표현 (0) | 2018.01.28 |
Programmers Level 3 다음 큰 숫자 (0) | 2018.01.28 |
Programmers Level 3 야근 지수 (0) | 2018.01.28 |