Answers for "missing integer c#"

C#
0

missing integer c#

public int solution(int[] A)
    {
        var val = new HashSet<int>(A).Where(x => x >= 1).OrderBy((y) =>y).ToArray();
        var minval = 1;
        for (int i = 0; i < val.Length; i++)
        {
            if (minval < val[i])
            {
                return minval;
            }
            minval = val[i] + 1;
        }

        return minval;
    }
Posted by: Guest on October-14-2021

C# Answers by Framework

Browse Popular Code Answers by Language