Tableau Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: In-Person
1. Assume the buildings are represented as the triplets of coordinates {(xb, xe) (yb, ye) (zb, ze)}
2. Assume also that we can ignore Z axis ie all the buildings are far enough from us and their width is not important
3. Sort in ascending order by the smallest x coordinate (xb) for each building
4. Pseudo code for the skyline length computation. Note that it is not important
which building is higher, if there is an overlap between two.
length = x0e - x0b /*set initial skyline length to the length of the leftomost building*/
end = x0e
for (int i = 1, i < num_of_buildings; i++) {
if (Xib < end) {
if (Xie < end) /*the next building is totally contained in the prev*/
continue;
else
length += Xie - end; /* partially contained , add the relevant part*/
}
else /*not contained */
length += Xie - Xib;
/* advance the rightmost end of the skyline*/
end = Xie;
}
How are the buildings represented? 3d binary matrix or actual geometry?
- keenox September 25, 2015