Search⌘ K

DIY: The Skyline Problem

Understand how to solve the skyline problem by processing building coordinates to produce the city's outer contour as a list of critical points. Learn to merge horizontal segments and implement the drawSkyline method in JavaScript, enhancing your skills with real coding scenarios.

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
...