Deer Park

Deer Park

  • NA
  • 39
  • 0

Logic to check 3 consecutive sequence

Nov 1 2012 11:52 PM
So, I have a list of integers say -
set one - 1,2,3,22,34,21
set two - 2,4,5,3,7,8
set three - 5,9,8,1,2,3

I have a function which should return true or false based on if the list contains consecutive three sequence number. So the set one and set three mentioned above should return true if passed to the function since those set have 3 numbers in sequence consecutively. 

What the elegent way to do this? is it better to do it by checking each element of the array or is there a way to get this using Linq?
Please suggest.

Answers (6)