leetcode编程题-Single Number 1
2016-03-23 17:28
267 查看
1.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?
代码:
int singleNumber(int* nums, int numsSize) {
int x=0;
for(int i=0;i<numsSize;i++)
{
x^=nums[i];
}
return x;
}
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?
代码:
int singleNumber(int* nums, int numsSize) {
int x=0;
for(int i=0;i<numsSize;i++)
{
x^=nums[i];
}
return x;
}
相关文章推荐
- 20145129 《Java程序设计》第3周学习总结
- Java面向对象要点
- Java面向对象要点
- Java面向对象要点
- java web QQ(二)
- Goldengate简单搭建
- numpy、scipy、matplotlib安装与配置
- Ruby学习笔记4(范围,迭代器,异常处理)
- Qt上传文件
- java source attacher
- C内存分配方式与C++内存分配方式
- task4: 结对编程-词频统计[修改版]
- The Smallest String Concatenation 一道让自己崩溃的题
- SpringMVC返回json数据的配置方式
- C++: 高精度加法与高精度减法
- Qt OpenGL:学习现代3D图形编程之一,画一个三角形
- python之psutil模块获取系统信息
- java 通用的返回类
- Spring中@Async用法总结
- QT之中多个信号连接同一个槽【细说版】