每日一题:五 特别的数字

有一个数组一些数字。全部的数字是相等的,除了一个。试图找到它!数组

findUniq([ 1, 1, 1, 2, 1, 1 ]) === 2
findUniq([ 0, 0, 0.55, 0, 0 ]) === 0.55

规则:code

1 数组包含超过3个数字。

任务:io

1 找到数组中惟一的数字
function find_uniq($a) {

}

祝君好运!function

function find_uniq($a) {
  rsort($a);
  return $a[0] == $a[1] ? end($a) : $a[0];
}
相关文章
相关标签/搜索