Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using System.Linq;
- namespace ConsoleApp3
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> list = new List<int> { 30000, 30001, 30003, 30004 };
- var next = list[list
- .OrderBy(i => i)
- .Skip(1)
- .Zip(list, (curr, prev) => curr - prev)
- .Select((diff, index) => new { diff, index })
- .First(x => x.diff > 1).index] + 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement