首页 > 其他 > 详细

LeetCode "The Skyline Problem"

时间:2015-05-29 07:22:56      阅读:2068      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!