There are 2 byte arrays. Pretty big. In both arrays there are all bytes (from 0 to 255).
We need an algorithm that finds matching chains in arrays so that:
- The first array was covered with chains of the second without intersections.
- Chains should be as small as possible (that is, the longest is in priority).
It is difficult to explain, so I will show by example.
There is a class for storing information about the chain.
public class PartInfo { public long Count { get; set; } public long Offset { get; set; } } there are 2 arrays
var arr1 = new byte[]{2,3,5,2,7,3,9}; var arr2 = new byte[]{2,3,9,5,2,7,8,6,3,9}; As a result, I expect to receive PartInfo[] with this content.
Count | Offset 2 | 0 3 | 3 2 | 8 so that having the second array and this summary information I was able to fully restore the first one.
Lead time matters
If something is not clear, ask leading questions.