What’s the most efficient way to get a first free spot from sorted query returning int collection ?
eg.: {1,2,3,4,6} | result.: 5
At the moment I am using foreach and counter that compares current value from sorted quety.ToList()
which takes about 600ms on 100 000 records.
Unless you multithread it, reading one at a time is your fastest solution since this is an O(n) problem.