leetcode之Single Number
2014-12-06 14:41
316 查看
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?
问题链接
cpp代码如下:
class Solution {
public:
int singleNumber(int A[], int n) {
int ans=0;
for(int i=0;i<n;++i){
ans^=A[i];
}
return ans;
}
};
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
问题链接
cpp代码如下:
class Solution {
public:
int singleNumber(int A[], int n) {
int ans=0;
for(int i=0;i<n;++i){
ans^=A[i];
}
return ans;
}
};
相关文章推荐
- [leetcode]Single Number
- LeetCode 136: Single Number
- [LeetCode] Single Number
- Leetcode::Single Number
- [算法][LeetCode]Single Number——异或运算的巧妙运用
- Single Number(leetcode)
- LeetCode 136 Single Number
- leetcode - Single Number
- 【leetcode】Single Number (Medium) ☆
- LeetCode题解:Single Number
- leetcode136: Single Number
- [LeetCode] Single Number
- LeetCode(136) Single Number
- LeetCode 136:Single Number
- LeetCode:Single Number
- LeetCode || Single Number
- LeetCode笔记:136. Single Number
- LeetCode--Single Number
- leetcode刷题17:single number 2
- [LeetCode] Single Number