Given a non-empty array of integers, every element appears twice except for one. Find that single one.

Note:

Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?

Example 1:

Input: [2,2,1]
Output: 1

Example 2:

Input: [4,1,2,1,2]
Output: 4
 
class Solution:
def singleNumber(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
nums.sort()
n=len(nums) i=0
while i!=n:
if i==n-1 or nums[i]!=nums[i+1]:
return nums[i]
i+=2

  

最新文章

  1. 关于ubuntu16无线网卡RTL8723BE频繁掉线及信号不足的解决办法
  2. 查找增强出口和BADI程序
  3. 提升你的开发效率,10 个 NPM 使用技巧
  4. Random()方法的使用
  5. UnitTest
  6. ocp 1Z0-047 131-276题解析
  7. mysql 一个较特殊的问题:You can't specify target table for update in FROM clause
  8. im消息丢失插件
  9. uber在限制新司机加入了,看看新政策把
  10. ubuntu的常用命令
  11. cookie笔记(一)
  12. scrapy爬取极客学院全部课程
  13. 【UML 建模】在线UML建模工具 ProcessOn 使用详解
  14. Java Trie字典树,前缀树
  15. 进程命令(tasklist)
  16. Redmine(window7)安装
  17. 【Java基础】浅谈常见设计模式
  18. ubuntu下定时任务的执行
  19. VLAN报文和非VLAN以太网报文的区别
  20. 【洛谷P1198】最大数

热门文章

  1. [ios]ios读写文件本地数据
  2. Flutter学习笔记(三)-- 事件交互和State管理
  3. Java-Java面向对象程序设计
  4. org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 问题解决方法
  5. 在WPF中添加Windows Form控件(包括 ocx控件)
  6. GitHub出现Permissiondenied (publickey).
  7. SMTP 发邮件
  8. 87. Scramble String *HARD* 动态规划
  9. mybatis标签之——<trim>
  10. POJ 2752 KMP中next数组的理解