缺失数字问题

Posted Alice_yufeng

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了缺失数字问题相关的知识,希望对你有一定的参考价值。

class Solution 
    public int missingNumber(int[] nums) 
        int length = nums.length;
        int sum = (0 + length) * (length + 1) / 2;
        for (int i = 0; i < length; i++)
            sum -= nums[i];
        return sum;
    

以上是关于缺失数字问题的主要内容,如果未能解决你的问题,请参考以下文章