一、leetcode地址
https://leetcode.com/problems/single-number/
二、问题描述
三、代码实现
语言:Python3
代码:
class Solution:
def singleNumber(self, nums: List[int]) -> int:
ans = 0
for num in nums:
ans = ans ^ num
return ans
https://leetcode.com/problems/single-number/
语言:Python3
代码:
class Solution:
def singleNumber(self, nums: List[int]) -> int:
ans = 0
for num in nums:
ans = ans ^ num
return ans