Загрузка страницы

The Skyline Problem

A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are given the locations and height of all the buildings, write a program to output the skyline formed by these buildings collectively. The skyline would be returned as a set of key points.

Algorithm in short -

1. Compare key points of skylines starting from leftmost end.
Choose the one having lesser of ‘x’ value.

2. If ‘y’ value of chosen key point is less than last seen height of other skyline, update key point’s ‘y’ to last seen height of other skyline.

3. Proceed to next key point of the chosen skyline.

4. Repeat above steps till both the skylines are completed.

5. Remove the redundant key points.

Website: http://www.ideserve.co.in

Facebook: https://www.facebook.com/IDeserve.co.in

Видео The Skyline Problem канала IDeserve
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
26 августа 2015 г. 2:38:41
00:19:37
Яндекс.Метрика