Find that single one.(linear runtime complexity0
2015-11-18 15:34
369 查看
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的部分是不同的·
相关文章推荐
- jQuery遍历json
- 黑马程序员——Java基础——继承之内部类(四)
- DATE_FORMAT函数用法
- JS UrlEncode UrlDecode
- 内存分析工具 MAT 的使用
- oracle 级联删除
- 2.mysql学习笔记:恢复mysql的root密码
- myeclipse中导入项目,中文出现乱码
- bootstrap栅格布局
- 下载、安装、使用CocoaPods
- HTML学习5:常用标签之表单标签
- 读大侠博客思考
- Diving into OpenStack Network Architecture - Part 4 - Connecting to Public Network
- C++ 显式调用DLL
- Dreamweaver支持cshtml的设置方法
- Edittext的seterror方法不显示
- [置顶] web站点过防火墙,安全狗常见技巧分享
- CentOS 7 中firewall-cmd命令
- 将nginx编译成静态库
- 重装mysql安装最后一项的apply security settings 总是不能进行。提示error nr.1045然后就是access denied for user 'root' @'loca