MENU

LeetCode268. 缺失数字

July 9, 2018 • Read: 2722 • LeetCode阅读设置

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;
    }
}
Last Modified: May 12, 2021
Archives Tip
QR Code for this page
Tipping QR Code