MENU

LeetCode268. 缺失数字

July 9, 2018 • Read: 177 • LeetCode

image

class Solution {
    public int missingNumber(int[] nums) {
        int sum = (1 + nums.length) * nums.length / 2;
        for(int i = 0;i < nums.length;i++)
            sum -= nums[i];
        return sum;
    }
}
最后编辑于: October 10, 2018
Archives Tip
QR Code for this page
Tipping QR Code