leetcode-218-The Skyline Problem

本文探讨了基于事件类型的数组排序方法,详细介绍了如何根据不同事件的起点和终点进行分类处理,使用优先队列和哈希映射来跟踪当前最大高度,并在特定条件下将元素插入结果集。特别注意的是,当遇到相同索引时,应遵循特定的排序规则。

Error:
cannot solve it.

  1. sort the array base on event type and its index
  2. handle it with different case:
    - when meet start point and its height is higher than current max., insert it to res
    - when meet end point and 1) current max. equal to its height, 2) no other pointer’s height in the queue has same height as end point, insert it to res

Note:

  1. careful with the sorting, if has same index, 1)sort larger first when start and 2) sort smaller first when end 3) if one is start and one is end, put start first
  2. take care of end type, first use a priority queue to keep track current max. height, and use hashmap to know current height number
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值