1

I just can't figure out a nice way to solve the following problem:

For an event I have n parties (party_id) taking part. Each party has m availabilities for said event in the form of start_date and end_date.

What I would like to know is all possible combinations of overlapping availabilities containing exactly one availability for each party_id. I discovered Interval Trees (https://en.wikipedia.org/wiki/Interval_tree) which might be utilized, but as I said I can't quite figure it out.

So thanks for any thoughts on that!

4

1 回答 1

1

start_date最直接的方法是按时间对所有事件(和类似事件)进行排序end_date。然后按时间顺序浏览此列表,同时跟踪所有“活动”方(即那些已经开始但未停止的方)。

上述方法是一个批处理,它应该可以让您轻松找到给定时间表的所有可能组合。您提到的间隔树在您想要增量更新您的一组方的情况下很有用 - 数据结构可以使关于特定时间的单个查询比为每个更新或查询重新运行批处理过程便宜得多。

于 2017-09-11T19:24:49.720 回答