One of my colleagues asked me to give a solution for following question.
In one data set (actually a data table), there are three fields, Item, Line Number, and Sequence.
In the data set, one Item has one or many Lines, and one line has a sequence starting from zero.
After some records were removed, we need find out missing sequence numbers. If a record in a maximum sequence number is removed, the whole sequence of the Item/Line is still in a sequential order, so it’s ok. However, if it’s not a maximum sequence number, the number is missing.
I believe that it’s not too difficult to get the result either by SQL or by LINQ. Could anyone give us solution by math or by an approach based on any math theory?
In one data set (actually a data table), there are three fields, Item, Line Number, and Sequence.
In the data set, one Item has one or many Lines, and one line has a sequence starting from zero.
After some records were removed, we need find out missing sequence numbers. If a record in a maximum sequence number is removed, the whole sequence of the Item/Line is still in a sequential order, so it’s ok. However, if it’s not a maximum sequence number, the number is missing.
I believe that it’s not too difficult to get the result either by SQL or by LINQ. Could anyone give us solution by math or by an approach based on any math theory?