mycode   75.80%

class Solution(object):
def singleNumber(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
res = nums[0]
for i in nums[1:]:
res = res ^ i
return res

参考:

class Solution:
def singleNumber(self, nums):
store = set()
for num in nums:
if num in store:
store.remove(num)
else:
store.add(num)
return list(store)[0]

leetcode-easy-array-136. Single Number的更多相关文章

  1. [LeetCode&Python] Problem 136. Single Number

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

  2. LeetCode 136. Single Number C++ 结题报告

    136. Single Number -- Easy 解答 相同的数,XOR 等于 0,所以,将所有的数字 XOR 就可以得到只出现一次的数 class Solution { public: int ...

  3. leetcode 136 Single Number, 260 Single Number III

    leetcode 136. Single Number Given an array of integers, every element appears twice except for one. ...

  4. LeetCode 136. Single Number(只出现一次的数字)

    LeetCode 136. Single Number(只出现一次的数字)

  5. leetcode 136. Single Number 、 137. Single Number II 、 260. Single Number III(剑指offer40 数组中只出现一次的数字)

    136. Single Number 除了一个数字,其他数字都出现了两遍. 用亦或解决,亦或的特点:1.相同的数结果为0,不同的数结果为1 2.与自己亦或为0,与0亦或为原来的数 class Solu ...

  6. 136. Single Number - LeetCode

    Question 136. Single Number Solution 思路:构造一个map,遍历数组记录每个数出现的次数,再遍历map,取出出现次数为1的num public int single ...

  7. LeetCode(137) Single Number II

    题目 Given an array of integers, every element appears three times except for one. Find that single on ...

  8. 【LeetCode】136. Single Number 解题报告(Java & Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 异或 字典 日期 [LeetCode] 题目地址:h ...

  9. LeetCode 136 Single Number(仅仅出现一次的数字)

    翻译 给定一个整型数组,除了某个元素外其余元素均出现两次. 找出这个仅仅出现一次的元素. 备注: 你的算法应该是一个线性时间复杂度. 你能够不用额外空间来实现它吗? 原文 Given an array ...

  10. [LeetCode] 136. Single Number 单独数

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

随机推荐

  1. 89. Gray Code (Java)

    The gray code is a binary numeral system where two successive values differ in only one bit. Given a ...

  2. NativeScript —— 初级入门(跨平台的手机APP应用)《二》

    NativeScript项目结构 根文件夹 package.json —— 这是适用于整个应用程序的NativeScript主项目配置文件. 它基本概述了项目的基本信息和所有平台要求. 当您添加和删除 ...

  3. 渗透神器CobaltStrike 3.1.2 去后门破解版 & Windows版TeamServer【转】

    转自我八师傅博客 CS简介 Cobalt Strike(简称CS)是全球黑客公认一款非常优秀的渗透测试神器,以metasploit为基础的GUI的框架式渗透工具,集成了传统远控功能(远程桌面VNC.键 ...

  4. Woobuntu

    Wooyun + Ubuntu = Woobuntu Woobuntu是基于Ubuntu系统的一款安全研究环境配置工具,可以自动安装并配置众多的安全工具与依赖环境,此外还针对中国用户的习惯进行了一些优 ...

  5. centos7 yum快速安装LNMP

    1.安装nginx yum install nginx ##开启nginx service nginx start 2.安装MYSQL yum localinstall http://dev.mysq ...

  6. 【2019.3.20】NOI模拟赛

    题目 这里必须标记一下那个傻逼问题,再不解决我人就没了! 先放一个 $T3$ $20$ 分暴力 #include<bits/stdc++.h> #define rep(i,x,y) for ...

  7. 【HDU2204】Eddy's爱好

    题目大意:求从 1 到 N 中共有多少个数可以表示成 \(M^K,K \gt 1\).\(N \le 1e18\) 题解: 发现 N 很大,若直接枚举 M 的话有 1e9 级别的数据量,肯定超时,因此 ...

  8. 三大方面,分析 to B和 to C产品的区别

    作为互联网从业者,我们经常听到to B(或2B)和to C(或2C)两个概念.to B即面向企业客户,to C即面向普通用户.只要是互联网人基本都懂知道这两个概念,但如果别人再问“to B和to C产 ...

  9. linux完整卸载mysql数据库

    由于本机测试环境数据库装错了,需要卸载数据库,记录一下 yum -y remove mysql find / -name mysql /etc/selinux/targeted/active/modu ...

  10. CAP拾遗

    概念 在一个分布式系统(指互相连接并共享数据的节点的集合)中,当涉及读写操作时,只能保证一致性.可用性.分区容错性三者中的两个,另外一个必须被牺牲 Consistency 对某个指定的客户端来说,读操 ...