// Given an array nums containing n distinct numbers in the range [0, n], // return the only number in the range that is missing from the array.
function missingNumber($nums) {
    sort($nums);
    foreach ($nums as $key => $num) {
        if ($key != $num) {
            return $key;
        }
    }
    return count($nums);
}
echo missingNumber([0, 3, 1]); // 2 echo missingNumber([0, 1]); // 2
by Luka Khitaridze
2 years ago
PHP
Array
0
Pro tip: use ```triple backticks around text``` to write in code fences