C# Missing Integer
static int MissingInteger(int[] a)
{
    var min = 1;
    var distinct = new HashSet<int>(a).ToList();
    distinct.Sort();

    foreach (var v in distinct)
    {
        if (v > 0)
        {
            if (min != v)
            {
                break;
            }
            min++;
        }
    }

    return min;
}

This records the positive numbers that exist, then returns the smallest positive value that is still missing.