c# - Find first free element -
i looking query return first number not available in list
int[] list = new int[] { 1,4,2,5,6,7 };
for above example expect have result 3.
perhaps this:
int result = enumerable.range(1, list.length) .where(i => !list.contains(i)) .firstordefault();
this return 0
if list
contains integers 1 n.
Comments
Post a Comment