Lonely Integer

There are N integers in an array A. All but one integer occurs in pairs. Your task is to find out that number that occurs only once.

Input Format

The first line of the input contains an integer N indicating N integers in the array A. Next line contains N integers each separated by a single space.

Constraints

1 <= N < 100
N % 2 = 1 ( N is an odd number )
0 <= i <= 100, ∀ i ∈ A

Output Format

Output (S) which is the number that occurs only once.

Sample Input:1

1
1

Sample Output:1

1

Sample Input:2

3
1 1 2

Sample Output:2

2

Sample Input:3

5
0 0 1 2 1

Sample Output:3

2

Explanation

In the first input, we see only 1 element and that element is the answer (1)
In the second input, we see 3 elements, 1 is repeated twice, the only other element 2 is the answer
In the third input, we see 5 elements, 1 and 0 are repeated twice, the other element 2 is the answer  

 

Solution coming soon…..

Advertisements

About qainterviews

Software Geek,QA Expert,Blogger
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s