Solving The Skyline Problem in go. Please try yourself first to solve the problem and submit your implementation to LeetCode before looking into solution.

Problem Description

For instance, the skyline in Figure B should be represented as:[ [2 10], [3 15], [7 12], [12 0], [15 10], [20 8], [24, 0] ].

Notes:

  • The output list must be sorted by the x position.

      events = {{x: L , height: H , type: entering},
                {x: R , height: H , type: leaving}}
      event.SortByX()
      ds = new DS()
    
      for e in events:
          if entering(e):
              if e.height > ds.max(): ans += [e.height]
              ds.add(e.height)
          if leaving(e):
              ds.remove(e.height)
              if e.height > ds.max(): ans += [ds.max()]

See the full details of the problem The Skyline Problem at LeetCode

Originally posted at: @github.com/halfrost/LeetCode-Go