You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This discussion was converted from issue #15 on September 15, 2026 10:58.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Problem link
https://leetcode.com/problems/maximal-rectangle/
Problem Summary
2차원 배열에서 1로만 이루어진 가장 큰 직사각형의 넓이를 구하는 문제.
Solution
정사각형의 경우 간단한 DP로 가능한데 직사각형이므로 DP 풀이는 약간 복잡하다.
예전에 로이형 유튜브에서 보긴 해서 그 풀이로 가보기로 하자.
이전 문제인 84. Largest Rectangle in Histogram 문제를 응용하면 된다. 각 칸을 히스토그램의 칸이라 생각하고 아래 행으로 갈 때마다 1이면 바의 높이가 1씩 증가하는 것으로 생각할 수 있다. 0이면 0으로 처리한다.
여기서 첫 번째 행은 그대로
10100이지만 두 번째 행을 위로 쌓는다고 생각하면20211, 비슷하게31322,40030으로 할 수 있다. 이 높이들에 대해 84번 문제의 가장 큰 직사각형을 구하는 알고리즘을 사용하면 된다.Source Code
All reactions