1
var getSkyline = function (buildings) {6
for (let building of buildings) {7
points.push([building[0], building[2]]);8
points.push([building[1], -building[2]]);13
points.sort((a, b) => b[1] - a[1]);14
points.sort((a, b) => a[0] - b[0]);16
for (let point of points) {18
heights.push(point[1]);20
heights.splice(heights.indexOf(-point[1]), 1);22
let curHeight = heights.length == 0 ? 0 : Math.max(...heights);24
if (results.length == 0 || results[results.length - 1][1] != curHeight)25
results.push([point[0], curHeight]);