LeetCode-E-Single Number
2017-04-06 20:43
351 查看
题目
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?
解法
异或实现
class Solution { public: int singleNumber(vector<int>& nums) { int x = 0; for(int i = 0; i < nums.size(); ++i){ x = x ^ nums[i]; } return x; } };
相关文章推荐
- leetcode之Single Number
- LeetCode-Single Number
- [LeetCode]Single Number
- leetcode 136. Single Number
- 【LeetCode】(136)Single Number (Easy)
- [leetcode]Single Number
- leetcode - Single Number
- LeetCode 136 -Single Number ( JAVA )
- LeetCode 136. Single Number
- 【Leetcode】Single Number 系列问题
- leetcode刷题15:single number
- LeetCode 136. Single Number
- leetcode之136. Single Number
- 【LeetCode】136. Single Number
- LeetCode 136 Single Number
- leetcode(136)_Single Number
- <LeetCode OJ>Single Number( I / II / III )【136 / 137 / 260】
- Leetcode 136 Single Number
- LeetCode: Single Number
- [LeetCode] Single Number