Reputation: 1053
I came up with an interesting (I think) problem and can't find a solution. Is this NP-Complete maybe (like some other packing problems)? If so, how would the reduction go?
We are given an array 1..n with some elements occupied and list of lengths of segments. The question is, can we pack those segments into this array so that no segments overlap with each other and occupied elements?
Example, array: |_ _ _ _ x _ _ _ _ _ _| (x - occupied, and the underscore means it's free) and lengths: 3, 3, 4. The answer in this case is YES, because in fact we have two containers in this array: 4, 6 and we can pack first two segments in container with capacity 6 and the last one to the first container.
Upvotes: 2
Views: 285
Reputation: 33532
Let's try to formulate the reduction with the partition-problem as base-problem.
The partition problem is the task of deciding whether a given multiset S of positive integers can be partitioned into two subsets S1 and S2 such that the sum of the numbers in S1 equals the sum of the numbers in S2. (from wiki-link above).
Example:
Upvotes: 5