# 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?

Subscribe to see which companies asked this question

public class Solution {

public int singleNumber(int[] nums) {
int[] arr = new int[nums.length];
int r = 0;
for(int i = 0 ;i < nums.length ; i++)
arr[i] = 0;
for(int i = 0; i < nums.length ; i++){
for(int j = i+1 ; j <nums.length ; j++)
{
if(nums[i] == nums[j])
{
arr[i]=1;
arr[j]=1;
}
}
}
for(int i = 0 ; i < nums.length ;i++){
if(arr[i]==0)
r = i;
}
return nums[r];
}
}

#### LeetCode || Single Number II

2014-04-09 23:35:07

#### 136. Single Number [medium] (Python)

2016-07-29 14:30:31

#### LeetCode 137：Single Number II

2015-06-01 22:36:27

#### LeetCode 136 — Single Number（C++ Java Python）

2014-02-20 15:43:27

#### LeetCode 136：Single Number I

2015-05-12 19:51:37

#### single-number、single-number2，数组中只出现一次的数字

2016-05-27 20:17:00

#### LeetCode(137)Single NumberII

2014-02-09 10:15:27

#### 【LeetCode-面试算法经典-Java实现】【137-Single Number II（只字出一次的数字II）】

2015-08-18 06:24:21

#### [leetcode] 260.Single Number III

2015-08-17 17:42:59

#### LeetCode 136. Single Number 题解（C++）

2016-09-29 12:07:25