A easy solution


  • 0
    Z

    public class Solution {

    public int missingNumber(int[] nums) {
        int a=(1+nums.length)*nums.length/2,b=0,c=0,i=0;
        for(i=0;i<nums.length;i++)
        {
            c=nums[i];
            b=b+c;
        }
        return c=a-b;
        
    }
    

    }


Log in to reply
 

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