leetcode 136 single number
2016-05-03 10:00
483 查看
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
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
class Solution { public: int singleNumber(vector<int>& nums) { int answer=nums[0]; for(unsigned long i=1;i!=nums.size();++i) answer=answer^nums[i]; return answer; } };
相关文章推荐
- 通过 objc_setAssociatedObject alert 和 button关联 及传值
- PHP shuffle() 函数
- 往发件箱存短信
- 系统架构设计——设计模式之策略模式
- RxAndroid简单入门。
- 让自己也能使用Canvas
- 自动加载的两种办法
- Spring--Bean scope
- 函数
- 从儿时的科幻电影到spaceX的火箭回收
- 剑指offer 数组中只出现一次的数字
- mrp实例
- iOS开发数据库篇—FMDB简单介绍
- 开机不启动Mediatomb
- Node.js其他模块
- 文件的压缩和解压命令
- 列出文件夹下修改时间
- 多层嵌套List输出
- 登录盈盈理财
- ubuntu_ar命令(操作 ?.deb文件)