Solution for SKYLINE problem, in Java and Javascript