Largest Rectangle – Part 1

histogramOn and off, during the past couple days I spent time soling the Largest Rectangle challenged form HackerRank ( The challenge is described as follows:

“There are N buildings in a certain two-dimensional landscape. Each building has a height given by h in [1 : N]. If you join K adjacent buildings, they will form a solid rectangle of area K * min(h, … , h). Given N buildings, find the greatest such solid area formed by consecutive buildings”. Continue reading “Largest Rectangle – Part 1”