Back to problems

Compute city skyline outline

Algorithm · Google · Hard

Imagine a set of rectangular buildings placed along the flat ground line of a city. Each building is described by a triple [left, right, height], where left is the x-coordinate where the building begins, right is the x-coordinate where it ends, and height is the building's vertical extent. The building occupies every x-coordinate satisfying left <= x < right, and it rises from ground level to height. Different buildings may overlap horizontally. The visible outline, or…

Checking your access…