268. Missing Number

class Solution {

    /**
     * @param Integer[] $nums
     * @return Integer
     */
    function missingNumber($nums) {
        $count = count($nums);
        $total = ($count * $count + $count) / 2;
        return $total - array_sum($nums);   
    }
}

Last updated