码迷,mamicode.com
首页 > 其他好文 > 详细

LeetCode "The Skyline Problem"

时间:2015-05-29 07:23:59      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:

Good one. My first reaction to this problem is the same idea as this answer: https://leetcode.com/discuss/37365/accepted-c-solution-o-nlogn-using-maxheap

So basically we need a MaxHeap which supports add\remove\top operations. But in C++ priority_queue doesn‘t support removal of arbitary elements. You may think that your own heap is needed to code, but in the above link, some book-keeping work can be a workaround: we simply record which elements are removed, and we simply pop it out when necessary.

And another solution is "Divide and Conqure": https://leetcode.com/discuss/37444/my-220ms-divide-and-conquer-solution-in-python-o-nlogn

LeetCode "The Skyline Problem"

标签:

原文地址:http://www.cnblogs.com/tonix/p/4537480.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!