LeetCode之136. Single Number

--------------------------------------
一个数异或它自己会得到0,0异或n会得到n,所以可以用异或来消除重复项。
AC代码如下:
public class Solution {
public int singleNumber(int[] nums) {
int res=0;
for(Integer i:nums) res^=i;
return res;
}
}
题目来源: https://leetcode.com/problems/single-number/
LeetCode之136. Single Number的更多相关文章
- 【LeetCode】136. Single Number 解题报告(Java & Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 异或 字典 日期 [LeetCode] 题目地址:h ...
- 【LeetCode】136. Single Number (4 solutions)
Single Number Given an array of integers, every element appears twice except for one. Find that sing ...
- LeetCode Problem 136:Single Number
描述:Given an array of integers, every element appears twice except for one. Find that single one. Not ...
- 【一天一道LeetCode】#136. Single Number
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given a ...
- 【LeetCode】136. Single Number
题目: Given an array of integers, every element appears twice except for one. Find that single one. No ...
- Leetcode No.136 Single Number(c++实现)
1. 题目 1.1 英文题目 Given a non-empty array of integers nums, every element appears twice except for one. ...
- LeetCode 136. Single Number C++ 结题报告
136. Single Number -- Easy 解答 相同的数,XOR 等于 0,所以,将所有的数字 XOR 就可以得到只出现一次的数 class Solution { public: int ...
- leetcode 136 Single Number, 260 Single Number III
leetcode 136. Single Number Given an array of integers, every element appears twice except for one. ...
- LeetCode 136. Single Number(只出现一次的数字)
LeetCode 136. Single Number(只出现一次的数字)
随机推荐
- php设置浏览器响应时间
ini_set('max_execution_time', '0'); ‘0’表示不受时间限制,一般默认30s;
- Azure SQL Data Warehouse
Azure SQL Data Warehouse & AWS Redshift Amazon Redshift Amazon Redshift 是一种快速.完全托管的 PB 级数据仓库,可方便 ...
- java学习流程
J2SE 面向对象-封装.继承.多态内存的分析递归集合类.泛型.自动打包与解包.Annotation IO 多线程.线程同步 TCP/UDP AWT.事件模型.匿名类 正则表达式反射机制 2:数据库( ...
- BZOJ 3289: Mato的文件管理
3289: Mato的文件管理 Time Limit: 40 Sec Memory Limit: 128 MBSubmit: 2368 Solved: 971[Submit][Status][Di ...
- 下载imagenet2012数据集
摸索了一下,imagenet2012下载,跟大家分享一下 用迅雷会员加速都可以下载,有的用百度云也可以离线下载 http://www.image-net.org/challenges/LSVRC/20 ...
- JS中的decodeURIComponent和encodeURIComponent
两个函数可以对特定函数生成的密码字符串进行解密操作,就可以生成为未解密的字符串 使用方法: //加密 encodeURIComponent("http://www.cnblogs.com/7 ...
- Promise deeply lookup
Motivation Consider the following synchronous JavaScript function to read a file and parse it as JSO ...
- linux中ls命令
ls跟dos下的dir命令是一样的都是用来列出目录下的文件 ls参数: -a: ls -a 列出文件下所有的文件,包括以"."开头的隐藏文件(linux下文件隐藏文件是以.开头的, ...
- 直接操作 SDL_Overlay YUV叠加上的像素
根据这篇解码出yuv数据后 海思h264解码库 y,u,v数据全部存进数组内, IntPtr y = _decodeFrame.pY; IntPtr ...
- java中的equals()方法重写
如何java中默认的equals方法跟实际不符的话,需要重写equals方法.例如: public class TestEquals { public static void main(String[ ...