how to find the max sequence order number before missing element.
input - 123678 output -3
public static void Main()
{
List<int> nums = new List<int>(){1,2,3,6,7,8};
int count = nums.Count;
for(int i=0;i<count;i++){
if((nums[i+1]-nums[i])>1){
Console.WriteLine("Missed Element after digit :" [i]);
}
}
}
fiddle https://dotnetfiddle.net/Hkd0rx
error
Index was out of range. Must be non-negative and less than the size of the collection.