buildings[i] = [left, right, height], where left and right are the x-coordinates of its left and right walls and height is how tall it is. The houses are listed in non-decreasing order of left.
Describe the top outline of the silhouette as a list of points [x, y] in increasing order of x. Each point marks where the outline changes height: from x up to the next point the outline runs at height y. Bare ground between houses is part of the outline too (height 0). The last point always has height 0 and sits where the rightmost house ends.
No two consecutive points may have the same height: if the outline stays at one height over several stretches in a row, that is one stretch with one point.buildings=[[1, 4, 6], [2, 7, 3], [9, 11, 5]] → [[1, 6], [4, 3], [7, 0], [9, 5], [11, 0]]
From 1 to 4 the outline runs at height 6, then only the second house (height 3) is visible up to 7, from 7 to 9 there is bare ground, and then the third house rises to 5 until 11.
buildings=[[0, 3, 2], [3, 6, 2]] → [[0, 2], [6, 0]]
Two houses of the same height stand side by side, so the outline is a single flat segment from 0 to 6 and there is no point at 3.
buildings=[[2, 8, 4], [3, 5, 9]] → [[2, 4], [3, 9], [5, 4], [8, 0]]
A tall house stands in front of a low one: the outline climbs from 4 to 9 between 3 and 5 and drops back to 4.
buildings is sorted by left in non-decreasing orderbuildings=[[1, 4, 6], [2, 7, 3], [9, 11, 5]]
[[1, 6], [4, 3], [7, 0], [9, 5], [11, 0]]
Run checks the first 3 tests in your browser. Submit checks all 85 tests on the server, hidden ones included.