mycode   80.25%

class Solution(object):
def missingNumber(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
Max = len(nums)
t = {i for i in range(Max+1)}
f = set(nums)
return (t - f).pop()

参考

def missingNumber(nums):
"""
:type nums: List[int]
:rtype: int
"""
res = len(nums)
print(res)
for i in range(len(nums)):
res ^= (i ^ nums[i])
print(i,nums[i],i^nums[i],res)
return res
#最初设置返回值res是nums的长度,目标值i^现有值nums[i],那么如果i和nums[i]是相同的,异或的结果就是0,再让res^该结果,那么res仍等于res,这样说明i这个数是存在的,也就是说所有相同的数都被变成了0,剩下的就是缺失的数

最新文章

  1. Python PIP安装
  2. 微软往年校招招面试题AC全解。
  3. Qt 二维码
  4. Android 回调接口是啥,回调机制详解(zhuan)
  5. 【SQL篇章--基于MySQL5.7--创建用户】
  6. 2014.7.12 敏捷个人奥森健步走&敏友分享会.活动报道
  7. codeforces 712B B. Memory and Trident(水题)
  8. python的Error集,17个新手常见Python运行时错误
  9. position relative和absolute区别
  10. IAR和Keil文件包含路径设置
  11. Xcode 7.0 官方免费的真机开发
  12. pytorch入门与实践-3 Tensor详解
  13. [android] 保存文件到SD卡
  14. Android联系人列表实现
  15. Linux进程调度器的设计--Linux进程的管理与调度(十七)
  16. WiFi-ESP8266入门http(3-3)网页认证上网-post请求-ESP8266程序
  17. 微信小程序框架——wepy使后感
  18. linux sftp远程上传文件
  19. jquery常用指令
  20. python 冷知识

热门文章

  1. python 装饰器,生成器,迭代器
  2. SVM处理多分类问题
  3. 【项目构建工具】 Gradle笔记2
  4. Linux6上安装MySQL
  5. 使用Ant打包工具
  6. 【异常】org.apache.hadoop.hbase.client.RetriesExhaustedException: Failed after attempts=36, exceptions:
  7. Boston Key Party 2015 Heath Street 题解(Writeup)
  8. linux进程间的通信方式
  9. Adaptive Synchronization of Dynamics on Evolving Complex Networks
  10. Linux 指令总结