public class Solution {
public int singleNumber(int[] nums) { int temp = 0;
for (int i=0;i<nums.length;i++)
{
temp = temp^nums[i];
}
return temp;
}
}

Given an 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?

Subscribe to see which companies asked this question

相异为1;找到相等的部分;为1的部分是不同的·

Find that single one.(linear runtime complexity0的更多相关文章

  1. [LeetCode] Single Number III 单独的数字之三

    Given an array of numbers nums, in which exactly two elements appear only once and all the other ele ...

  2. [LeetCode] Single Number II 单独的数字之二

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

  3. [LeetCode] Single Number 单独的数字

    Given an array of integers, every element appears twice except for one. Find that single one. Note:Y ...

  4. LeetCode——Single Number II(找出数组中只出现一次的数2)

    问题: Given an array of integers, every element appears three times except for one. Find that single o ...

  5. [LeetCode] Single Number

    Given an array of integers, every element appears twice except for one. Find that single one. Note: ...

  6. 【LeetCode】Single Number I & II & III

    Single Number I : Given an array of integers, every element appears twice except for one. Find that ...

  7. Single Number

    Given an array of integers, every element appears twice except for one. Find that single one.Your al ...

  8. (Array,位操作)137. Single Number II

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

  9. 【leetcode】Single Number II (medium) ★ 自己没做出来....

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

随机推荐

  1. 联想e431笔记本更改硬盘模式bios设置的详细教程

    用硬盘安装系统,就要进入bios,将硬盘改为第一启动项即可重装系统.不同品牌的电脑,它的bios设置方法也就不同.那么,联想e431笔记本要如何更改硬盘模式呢?今天U大侠小编就和大家分享联想e431笔 ...

  2. Objective-C中关于NSArray, NSDictionary, NSNumber等写法的进化

    从xcode4.4开始,LLVM4.0编译器为Objective-C添加一些新的特性.创建数组NSArray,哈希表NSDictionary, 数值对象NSNumber时,可以像NSString的初始 ...

  3. SpringAOP 设计原理

    1.  设计原理 引入了,代理模式. java 程序执行流: 如果从虚拟机的角度看,整个程序的过程就是方法的调用,我们按照方法的执行顺序,将方法调用成一串. 在方法之间有着Join Point 连接点 ...

  4. for..in...时,注意hasOwnProperty验证

    for..in...时,注意hasOwnProperty验证 var obj = { a: 10, b: 20 }; // 注意词句代码 Object.prototype.c = 30; var it ...

  5. centos7设置sshd端口,firewall,selinux设置

    https://blog.csdn.net/qq_31927797/article/details/81095829 #停止firewallsystemctl stop firewalld.servi ...

  6. common-fileupload上传文件

    文件上传在web应用中非常普遍,要在jsp环境中实现文件上传功能是非常容易的,因为网上有许多用java开发的文件上传组件,本文以commons-fileupload组件为例,为jsp应用添加文件上传功 ...

  7. 企业版https

    http://www.cocoachina.com/bbs/read.php?tid=194213

  8. bzoj5469 [FJOI2018]领导集团问题

    题目描述: bz luogu 题解: 相当于树上$LIS$问题. 考虑一维情况下的贪心,我们可以用multiset启发式合并搞. 代码: #include<set> #include< ...

  9. 如何利用 CSS 动画原理,在页面上表现日蚀现象

    效果预览 在线演示 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/OELvrK 可交互视频教 ...

  10. CSS盒模型-box-sizing

    CSS中Box model是分为两种,第一种是W3C的标准模型,另一种是IE的传统模型 1.W3C的标准Box Model: /*外盒尺寸计算(元素空间尺寸)*/ Element空间高度 = cont ...