C# with bool array


  • -1
    D
                bool[] zz = new bool[nums.Length];
                int i;
                for (i = 0; i < nums.Length; i++)
                {
                    if (nums[i] <= nums.Length && nums[i] > 0)
                        zz[nums[i] - 1] = true;
                }
                for (i = 0; i < zz.Length; i++)
                    if (!zz[i])
                        return i + 1;
                return zz.Length + 1;

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.