@lcn said in (Guaranteed) Really Detailed and Good (Perfect) Explanation of The Skyline Problem:

Collections.sort(ends, (a, b) -> a[0] == b[0] ? (a[1] == b[1] ? (a[1] == 0 ? b[2] - a[2] // left end with smaller height comes after left ends with the same coordinate : a[2] - b[2]) // and vice versa for right ends : a[1] - b[1]) // right end comes after left if coordinates are the same : a[0] - b[0]); // regular order when coordinates differ

In this can someone please tell me what is being done here

(a[1] == 0 ? b[2] - a[2] // left end with smaller height comes after left ends with the same coordinate : a[2] - b[2]) // and vice versa for right ends

If two rectangle have same coordinate and they both are either start(left) or end(right) then if they both are starts we want to process the one with larger height? Why?