Any sub O(n^2) soluton?
Latest FizzBuzz:
https://leetcode.com/problems/the-skyline-problem/
can you find an O(n*log2(n)) solution?
My O(n^2) solution (inner for loop gives the square)
Input: [2 9 10] [3 7 15] [5 12 12] [15 20 10] [19 24 8]
Output:
Open!
CurId MaxY -1
for X,Y,Id,End Input.i{[@?1 ?0]}{[?0 ?2 ?3 0],[?1 ?2 ?3 1]}.j.sortBy(?0):
less End:
Open.Id = Y
if MaxY < Y:
[Id Y](:&CurId,&MaxY)
push X,Y Output
pass
Open.del Id
less Id><CurId: pass
[-1 -1](:&CurId,&MaxY)
less Open.n: | push X,0 Output; pass
Open.l.maxf(?1)(:[&CurId &MaxY])
push X,MaxY Output
say Output.f