Search⌘ K
AI Features

DIY: The Skyline Problem

Explore how to implement the Skyline Problem by constructing the city skyline from building coordinates and heights. Discover techniques to merge segments and optimize the skyline representation. This lesson helps you understand how to process and sort building data to create the outer contour, preparing you for similar coding interview questions.

Problem statement

Given a buildings list, you have to draw the skyline of the outer contour of the city. The citys’ skyline is formed by the silhouette of all of its buildings. Each building in this buildingslist consists of the following information:

  • lefti: The x-coordinate of the left edge of the building.
  • righti: The x-coordinate of the right edge
...