In my over-long running thread about Finding Matching Ints (initial posting), I have have come across another solution from a php developer that I recently interviewed… in php.

1
2
3
4
5
6
7
8
9
function findInts($array){
    $out = Array();
    foreach($array as $num){
        if(array_exist($out,$num){
            return $num;
        }
        array_push($num);
    }
}

He also mentioned the pre-sorting approach as well in order to speed things up. I still need to fully validate the php functions that he mentions, but it seems correct. I also didn’t go into the error-case much with him, not really being a php expert myself.

Popularity: 3% [?]

  • Share/Bookmark

Tags: , ,