You are viewing a single comment's thread. Return to all comments →
JavaScript solution:
function largestRectangle(h) { let biggest = 0; for (let i = 0; i < h.length; i++) { let minHeight = h[i]; for (let j = i; j < h.length; j++) { minHeight = Math.min(minHeight, h[j]); let area = minHeight * (j - i + 1); biggest = Math.max(biggest, area); } } return biggest; }
Seems like cookies are disabled on this browser, please enable them to open this website
Largest Rectangle
You are viewing a single comment's thread. Return to all comments →
JavaScript solution: