力扣 136. 只出现一次的数字

位运算

1
2
3
4
5
6
def singleNumber(nums):
# 位运算
ret = nums[0]
for i in range(1, len(nums)):
ret = nums[i] ^ ret
return ret
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2022 eightyninth
  • Visitors: | Views:

请我喝杯咖啡吧~

支付宝
微信