dsa2 min read
Largest Rectangle in Histogram [Hard] — Monotonic Stack
Find the largest rectangle in a histogram in O(n) using a monotonic increasing stack that computes area when a shorter bar is encountered.
Read →
webcoderspeed.com
1276 articles
Find the largest rectangle in a histogram in O(n) using a monotonic increasing stack that computes area when a shorter bar is encountered.
Find the minimum window in s that contains all characters of t using a shrinkable sliding window with a character frequency counter.
Count elements smaller than each element to its right using a modified merge sort that counts inversions during the merge step.
Find the median of two sorted arrays in O(log(min(m,n))) by binary searching for the correct partition point.
Find the largest rectangle of 1s in a binary matrix by treating each row as a histogram and applying the Largest Rectangle in Histogram algorithm.