Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int PickingNumbers(List<int> a)
- {
- int length = 0;
- int temp = 0;
- int firstNumberOfSeq = -1;
- a.Sort();
- for (int i = 1; i < a.Count; ++i)
- {
- int difference = a[i] - a[i - 1];
- if (firstNumberOfSeq == -1 && difference <= 1 && difference >= 0)
- {
- firstNumberOfSeq = a[i - 1];
- }
- if (a[i] - firstNumberOfSeq < 2)
- {
- temp++;
- }
- else
- {
- temp = 0;
- firstNumberOfSeq = -1;
- }
- if (temp > length)
- {
- length = temp;
- }
- }
- return length;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement