C# Solution (Single Number)


  • 0
    A
     public int SingleNumber(int[] nums)
            {
             int sNumber = nums[0]; 
                if (nums.Length > 1)
                {
                    for (int i = 0; i <= nums.Length - 2; i++)
                    {
                        sNumber = sNumber ^ nums[i + 1];
                    }
                }           
                return sNumber;
            }
    

Log in to reply
 

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