Gidhub BE Developer

가장 큰 정사각형 찾기

2018-07-25
goodGid

Problem

Problem URL : 가장 큰 정사각형 찾기

Screenshots of Problem Explain

Code


int dp[1001][1001];

int solution(vector<vector<int>> board){
    int answer = 0;
    int r_size = (int)board.size();
    int c_size = (int)board[0].size();
    
    for(int i=0; i<r_size; i++){
        for(int j=0; j<c_size; j++){
            if( i==0 || j == 0) {
                dp[i][j] = board[i][j];
                answer = answer < dp[i][j] ? dp[i][j] : answer;
                continue;
            }
            if(board[i][j]){
                dp[i][j] = min({ dp[i-1][j], dp[i][j-1], dp[i-1][j-1] }) + 1;
                answer = answer < dp[i][j] ? dp[i][j] : answer;
            }
        }
    }
    answer *=  answer;
    
    return answer;
}


Feed Back

Screenshots of Problem Explain

Comments

Content