Accepted c++ code


  • 0
    L

    int missingNumber(vector<int>& nums) {
    int length = nums.size();
    int sum = length*(length+1)/2;
    for(int i =0;i<length;i++){
    sum = sum - nums[i];
    }
    return sum;
    }


Log in to reply
 

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