Odd Man Out - GCJ 2010 (Africa)

Posted on April 10, 2010


Below is the problem statement of 'Odd Man Out' problem, from 'Google Code Jam 2010 (Africa)':

Problem
-------

You are hosting a party with G guests and notice that there is an odd number of guests! When planning the party you deliberately invited only couples and gave each couple a unique number C on their invitation. You would like to single out whoever came alone by asking all of the guests for their invitation numbers.

Input
-----

The first line of input gives the number of cases, N.
N test cases follow. For each test case there will be:

One line containing the value G the number of guests.
One line containing a space-separated list of G integers. Each integer C indicates the invitation code of a guest.

Output
------

For each test case, output one line containing "Case #x: " followed by the number C of the guest who is alone.

Limits
------

1 ≤ N ≤ 50
0 < C ≤ 2147483647 Small dataset ------------- 3 ≤ G < 100 Large dataset ------------- 3 ≤ G < 1000 Sample Input ------------ 3 3 1 2147483647 2147483647 5 3 4 7 4 3 5 2 10 2 10 5 Output ------ Case #1: 1 Case #2: 7 Case #3: 5


Below is the solution coded by me in Java:



Blog Categories
Disclaimer
The views expressed on this blog are my personal views and do not reflect the views of my employer or campaigns I am supporting.

All sample code is provided for illustrative purposes only. These examples have not been thoroughly tested under all conditions. The writer therefore, cannot guarantee or imply reliability, serviceability, or function of these programs.

All programs contained herein are provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.