Level
프로그래머스 Lv2
 
function solution(board)
{
    const colLength = board.length;
    const rowLength = board[0].length;
    
    // 첫 행, 첫 열 복사
    const copied = [board[0]]; 
    for(let i=1; i<colLength; i++){
        const row = Array(rowLength).fill(0);
        row[0] = board[i][0];
        copied.push(row);
    };
    
    for(let i=1; i<colLength; i++){
        for(let j=1; j<rowLength; j++){
            const p = board[i][j];
            if(p){
                copied[i][j] = Math.min(copied[i][j-1], copied[i-1][j], copied[i-1][j-1])+1;
            }
        }
    }

    return Math.max(...copied.map(row => Math.max(...row)))**2;

		// const rowMaxRadius = copied.map(row => Math.max(...row));
		// const maxRadius = Math.max(...rowMaxRadius);
		// const maxSquare = maxRadius**2;
}