Problem:

Given a series of integers such that each integer have a pair, only 1 integer is without pair. Find it

**Input Format:**

**Output Format:**

Integer without pair

**Constraints:**

none

Sample Input

1 3 5 7 3 5 2 1 2

Sample Output:

7

7

Explanations:

7 occurs only once, all other appears 2 ie in pair

7 occurs only once, all other appears 2 ie in pair

Solution:

@arr=split(" ",$line2);

@arr=sort{$a<=>$b}@arr;

$len=@arr;

for($i=0;$i<$len;$i++)

{

if($arr[$i] != $arr[$i+1])

{

print "$arr[$i]";

exit;

}

$i++;

}

Tips:

Simple enough, sort the list and compare pairs.

## No comments:

## Post a Comment