The Skyline Problem

Hard Intervals AI round

How it works

  1. Press Start. 30:00 on the clock, and it keeps running if you leave the page.
  2. Use an AI agent. 20 messages, anything about the problem. It can write code, but how you use it is scored.
  3. Run your code on the examples and your own cases, up to 20 runs in 10 minutes.
  4. Submit to run the hidden tests and end the round.

What the report looks at Example figures

  • SolutionOptimal · O(n)
  • Hidden tests12 of 12
  • AI agent use78 / 100
  • Cost$0.004
  • Time14:32 of 30:00

The problem

buildings lists buildings standing on flat ground, each [left, right, height]: a rectangle from left to right along the ground, height tall. They come in no particular order, and may touch, overlap or stand inside one another.

The skyline is the outline they make together, seen from far away. At each point along the ground its height is the height of the tallest building standing there, where a building stands from its left up to but not including its right; where none stands, the outline is on the ground, at height 0.

Return the skyline's key points [x, height] from left to right: one at each x where the outline's height changes, giving its new height, the last one where it comes down to the ground. No two points in a row have the same height.

Read the full problem

Solve it without the AI agent

Write it in Python, Java or C++, run it on your own cases, and submit against hidden tests.

Open the practice page

Watch the explanation

More Intervals

All Intervals problems