C++ AC Super Clean and Easy Understanding Code


  • 0
    H
    int minArea(vector<vector<char>>& image, int x, int y) {
            int m = image.size(), n = image[0].size();
            int up = INT_MAX, left = INT_MAX, down = INT_MIN, right = INT_MIN;
            
            for(int i = 0; i < m; i++){
                for(int j = 0; j < n; j++){
                    if(image[i][j] == '1'){
                        up = min(up, j);
                        down = max(down, j);
                        left = min(left, i);
                        right = max(right, i);
                    }
                }
            }
            
            return (down - up + 1)*(right - left + 1);
        }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.