We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Linux Shell
  3. Arrays in Bash
  4. Lonely Integer - Bash!

Lonely Integer - Bash!

Problem
Submissions
Leaderboard
Discussions

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

Input Format

The first line of the input contains an integer , indicating the number of integers. The next line contains space-separated integers that form the array .

Constraints


% ( is an odd number)

Output Format

Output , 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 one element (1) and that element is the answer.
In the second input, we see three elements; 1 occurs at two places and 2 only once. Thus, the answer is 2.
In the third input, we see five elements. 1 and 0 occur twice. The element that occurs only once is 2.

Author

PRASHANTB1984

Difficulty

Hard

Max Score

10

Submitted By

11760

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy