我在开展一个项目时就遇到了这一问题,并想知道解决这一问题的最佳方式:
Saye 我的分数间隔如下,我想在间隔期间找到最高分数。
3-8 20
4-10 40
8-12 10
9-13 20
其结果应为40+10+5 = 70
3-8 and 4-10 overlap at 4-8 with a total score of 40+20 = 60 4-10, 8-12, and 9-13, all overlap at 9-10 with a score of 40+10+20 = 70
Obviously we have other overlaps like every interval by itself, or 8-12 and 9-13 excluding 4-10, but those dont yield a maximum. I also ideally would want to return the overlap that yielded the max amount, which in this case would be the 9-10 interval, which corresponds to the interval at which all 3 intervals that yielded the max score amount share.
解决这一问题将是一个好的算法?
我最初的想法是按起点进行分类,然后检查以前的间隔是否重叠(这足够容易),我很快提出的问题是,我们有:
3-9 20
4-10 40
8-12 10
9-13 30
我们感到振奋的是,我们认为3-9重叠,4-10重叠,有60,3-9,4-10,8-12重叠,有70。 然而,当我们发现9-13时,我们需要稍加停止考虑3-9,现在看看看看4-10、8-12、9-13重叠、80和9-10重叠。 是否可能有滑坡窗口?