HTMLify
Day 69
Views: 2 | Author: djdj
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | class Solution { /** * @param Integer[] * @return Integer **/ function singleNumber($nums) { $result = 0; foreach ($nums as $num) { $result ^= $num; } return $result; } } /*class Solution { /** * @param Integer[] $nums * @return Integer ** function singleNumber($nums) { $count = array_count_values($nums); foreach ($count as $num => $freq) { if ($freq == 1) { return $num; } } } }*/ |