Programmers Level 4 땅따먹기 게임
def hopscotch(board, size): sumList = [0]*4 for row in board: tmp = sumList.copy() for i in range(len(row)): sumList[i] = row[i] + max(tmp[:i] + tmp[i+1:]) return max(sumList) #아래는 테스트로 출력해 보기 위한 코드입니다.board = [[ 1, 2, 3, 5 ], [ 5, 6, 7, 8 ], [4, 3, 2, 1]]print(hopscotch(board, 3))
Programmers Level 4 가장 큰 정사각형 찾기 ★
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**2testBoard = [['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(..