Finding a sequence in a List
Posted
by user113164
on Stack Overflow
See other posts from Stack Overflow
or by user113164
Published on 2010-03-11T21:16:13Z
Indexed on
2010/03/11
21:19 UTC
Read the original article
Hit count: 233
I have a list of integers that I would like to search for a sequence.
For example, if i have a master list: 1, 2, 3, 4, 9, 2, 39, 482, 19283, 19, 23, 1, 29
And I want to find sequence: 1, 2, 3, 4
I would like some easy way to fill a subset list with: 1, 2, 3, 4 + the next five integers in the master list
And then remove the integers in the subset list from the master list so at the end of the operation, my lists would look like this:
Master list: 19, 23, 1, 29
Subset list: 1, 2, 3, 4, 9, 2, 39, 482, 19283
Hope that makes sense. I'm guessing maybe linq would be good for something like this, but I've never used it before. Can anyone help?
© Stack Overflow or respective owner