[LeetCode]Single Number
2013-10-09 18:51
218 查看
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?
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
public class Solution { public int singleNumber(int[] A) { // Note: The Solution object is instantiated only once and is reused by each test case. int result = 0; if(A.length == 0) return 0; for(int i = 0;i<A.length;i++){ result ^= A[i]; } return result; } }
相关文章推荐
- 基于Visual C++2012拆解世界五百强面试题--题3
- Stimulsoft Reports筛选数据来绑定显示2个报表
- cocos2d-x中的CCTableView的相关用法
- java实现简单的文件筛选
- [置顶] cocos2dx sqllite 增删查改等操作
- tomcat在开发过程中使用ip地址无法访问的问题
- 规律踢
- hdu 3722 Card Game 二分图的最大权匹配
- 如何将中国知网CNKI中的文献导入EndNote X6
- BloomFilter--大规模数据处理利器
- uva 10099
- Oracle的DECODE()和CASE WHEN
- 计算机网络(笔记)
- 此时此刻的心情
- 内联函数
- Linux 文件系统
- [转]理解oracle的网络结构
- Java Details-抽象的类可以调用其静态方法
- 单例模式(Singleton Pattern)
- BZOJ 2933([Poi1999]地图-区间Dp)