[LeetCode 풀이/python] 85. Maximal Rectangle (hard)
문제 설명: 0 과 1 로만 채워진 rows x cols 형태의 행렬 matrix 가 주어졌을 때, 1 만 포함하는 가장 큰 직사각형을 찾고 그 넓이를 리턴하시오. (Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.) 예시 1) 입력: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]] --> 출력: 6 설명: 최대 크기의 직사각형은 위의 그림에 표시되어 있음 예시 2) 입력: matrix = [] --> ..
2021. 3. 7.
[LeetCode 풀이/python] 84. Largest Rectangle in Histogram (hard)
문제 설명: 정수 배열 heights 는 히스토그램 막대의 높이를 나타내며, 각 막대의 너비는 1 이다. 이 때, 히스토그램에서 가장 큰 직사각형의 넓이를 리턴하시오. (Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram.) 예시 1) 입력: heights = [2,1,5,6,2,3] --> 출력: 10 설명: 가장 큰 직사각형은 붉게 나타난 영역으로, 각 막대의 너비가 1 이므로 총 넓이 10 을 갖는다. 예시 2) 입력: heights = [2,4] --> ..
2021. 3. 7.