Leetcode no. 136
2016-06-06 11:45
120 查看
136. Single Number
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?
public class Solution {
public int singleNumber(int[] nums) {
int res=0;
for (int ele: nums){
res ^= ele;
}
return res;
}
}
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?
public class Solution {
public int singleNumber(int[] nums) {
int res=0;
for (int ele: nums){
res ^= ele;
}
return res;
}
}
相关文章推荐
- 微信 js api[转]
- iostat
- Tomcat war包应用发布简述
- BLE
- JAVA 使用Dom4j 解析XML
- surfaceview 失去焦点后重新创建问题
- sicily Tiling a Grid With Dominoes
- 第七次c++作业
- centOS6.5下安装jdk1.7
- BigDecimal.dive(one,scale,BigDecimal.ROUND_HALF_UP)不能四舍五入!!
- apache https ssl配置详细步骤讲解
- 转:C++ 性能测试支持
- quartz的定时任务使用的补充。
- 关于销售订单的状态
- Qemu下安装Sun Solairs8简明教程 转
- 线段余弦角+凸包算法
- ThinkPHP中简单的CURD操作
- 详解C中volatile关键字(转)
- Android性能优化总结
- C++Primer Chapter3课后习题