Skip to content

Latest commit

 

History

History
17 lines (16 loc) · 377 Bytes

268.md

File metadata and controls

17 lines (16 loc) · 377 Bytes

#268. Missing Number 题目链接

public class Solution {
    public int missingNumber(int[] nums) {
        int sum = 0;
        int sum2 = 0;
        for (int i = 0; i < nums.length; i++) {
            sum += i;
            sum2 += nums[i];
        }
        sum += nums.length;
        return sum - sum2;
    }
}