Odd Man Out
InterviewTime limit5sMemory limit512 MB
Given an odd-length list where every number appears twice except one, find the number that appears once.
- Level
Medium4 of 10
- Topics
- Bit manipulation, Hash map
- Solved
- No attempts yet
Problem
You are hosting a party for guests. You sent invitations to couples only, and each couple got its own invitation number , the same number for both partners. A couple adds two guests carrying the same number, so the guest count should be even. It is not: the number of guests who showed up is odd, so exactly one guest came alone.
You ask every guest for an invitation number and write the answers down. Find the invitation number of the guest who came alone.
Input
The first line contains the number of test cases .
Each test case is given on two lines.
- The first line contains the number of guests .
- The second line contains space separated integers, the invitation number of each guest.
Limits
- , and is odd.
- In each test case exactly one number appears once and every other number appears exactly twice.
Output
For each test case print one line containing Case #x: followed by the invitation number of the guest who came alone. Here is the test case number, counting from 1.