C# solution


  • 0
    public class Solution {
        public int MissingNumber(int[] nums) 
        {
            int sum = 0;
           for(int i = 0;i< nums.Length; i++)
           {
               sum+=nums[i];
           }
           
           return ( (nums.Length * (nums.Length + 1) ) - 2*sum) /2 ;
        }
    }
    

Log in to reply
 

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