The problem es essentially to map from an indiscrete space to a discrete one. The solution that comes into my mind is a simple sweep-line algorithm:
1. Take all the start x-coordinates of a buildings (=start events).
2. Take all the end x-coodinates of the buildings (=end events).
3. Sort all the events the by the value of the coordinate.
4. Now walk over all the events and keep count of how many there currently are (or in this case: how high the building is) by adding one for a start event and substracting one for a end event.