标签:gnu tin int missing The elf nbsp for col
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n
, find the one that is missing from the array.
给n个不同的数,求0-n这n+1个数里缺了哪个
利用异或运算的性质,可以on处理
class Solution(object): def missingNumber(self, nums): """ :type nums: List[int] :rtype: int """ ans = 0 for i in range(1, len(nums) + 1): ans ^= i for value in nums: ans ^= value return ans
标签:gnu tin int missing The elf nbsp for col
原文地址:https://www.cnblogs.com/whatyouthink/p/13254130.html