I come to your question after reading all the comments, This is an algorithm without extra space and O (n).
XORing , XOR - .
0, ,
else result XOR , TRUE.
(. http://codepad.org/qyzT1v4N):
<?php
function testUnique($arr){
$res = 0;
for($i=0;$i< count($arr);$i++)
{
$res ^= $arr[$i];
}
return ($res != 0);
}
$dup = array(1,1,3,3,2,2);
var_dump(testUnique($dup));
$dup = array(6,6,4,3,2,2);
var_dump(testUnique($dup));
?>