Leetcode 面试题 17.04 消失的数字

Leetcode 面试题 17.04 消失的数字

int missingNumber(int* nums, int numsSize)
{
	assert(nums);
	int ret = 0;
	for (int i = 0; i <= numsSize; i++)
	{
		ret ^= i;
	}
	for (int i = 0; i<numsSize; i++)
	{
		ret ^= nums[i];
	}
	return ret;
}

Leetcode 面试题 17.04 消失的数字_第1张图片

你可能感兴趣的:(开发语言,后端,c语言)