Algorithm to find the maximum sum in a sequence of overlapping intervals

前端 未结 6 923
南旧
南旧 2020-11-30 19:33

The problem I am trying to solve has a list of intervals on the number line, each with a pre-defined score. I need to return the maximum possible total score.

The c

6条回答
  •  眼角桃花
    2020-11-30 20:14

    Sounds like a variation on the Knapsack problem. You might find some inspiration in searching for those solutions.

    How many intervals are we talking about? If it's only about 5 (as in your example), it' probably more practical to just try every combination. If it's more, will an approximation of an ideal solution do? Again, Knapsack solutions (such as George Dantzig's greedy approximation algorithm) might be a good place to start.

提交回复
热议问题