int missingNumber(vector<int>& nums) {
int sum = 0;
int len = nums.size();
int total = len * (len - 1) / 2;
for (int i = 0; i < len; i++) {
sum += nums[i];
}
return total - sum;
}
leetcode刷题笔记 268.丢失的数字【简单】
最新推荐文章于 2024-06-14 22:04:21 发布