I want a method that can check if all elements from one list are in another list but in sequential order.
Example
List<int> list1 = new List<int>{ 1, 3, 4 };
List<int> list2 = new List<int>{ 1, 2, 3 };
List<int> list3 = new List<int>{ 1, 2, 3, 4, 5 };
if(IsInSequential(list1, list3)) // should return false
{
// stuff...
}
if(IsInSequential(list2, list3)) // should return true
{
// stuff...
}
if(IsInSequential(list3, list2)) // should return false
{
// stuff...
}
bool IsInSequential(List<int> list1, List<int> list2)
{
// ???
}
I was trying to use methods like Intersect
, Select
, Any
and other stuff but it was getting too complicated and i don't know if exists a more efficient way.