빠켱이

프로그래머스 가장 큰 정사각형 찾기[C++] 본문

알고리즘/프로그래머스 알고리즘

프로그래머스 가장 큰 정사각형 찾기[C++]

빠켱이 2021. 4. 5. 06:45
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int solution(vector<vector<int>> board)
{
    int answer = board[0][0];
    for(int i = 1; i < board.size(); i++){
        for(int j = 1; j < board[0].size(); j++){
            if(board[i][j] == 1){
                board[i][j] = 1 + min({board[i-1][j-1], board[i-1][j], board[i][j-1]});
                answer = max(answer, board[i][j]);
            }
        }
    }
    answer = answer * answer;
    return answer;
}
Comments