<?php
findMissing($list,1,100);
function findMissing($list, $min, $max) {
return;
}
$l = $r = [];
foreach($list as $number) {
if($number < $pivot) {
$l[] = $number;
}
else {
$r[] = $number;
}
}
if(count($l) == $pivot - $min - 1) { // only 1 missing number use difference of sums
}
else if(count($l) < $pivot - $min) { // more than 1 missing number, recurse
findMissing($l, $min, $pivot-1);
}
if(count($r) == $max - $pivot - 1) { // only 1 missing number use difference of sums
} else if(count($r) < $max - $pivot) { // mroe than 1 missing number recurse
findMissing($r, $pivot+1, $max);
}
}
PD9waHAKCiAgJGxpc3QgPSByYW5nZSgxLDEwMCk7CiAgdW5zZXQoJGxpc3RbM10pOwogIHVuc2V0KCRsaXN0WzMxXSk7CgogIGZpbmRNaXNzaW5nKCRsaXN0LDEsMTAwKTsKCiAgZnVuY3Rpb24gZmluZE1pc3NpbmcoJGxpc3QsICRtaW4sICRtYXgpIHsKICAgIGlmKGVtcHR5KCRsaXN0KSkgewogICAgICBwcmludF9yKHJhbmdlKCRtaW4sICRtYXgpKTsKICAgICAgcmV0dXJuOwogICAgfQoKICAgICRsID0gJHIgPSBbXTsKICAgICRwaXZvdCA9IGFycmF5X3BvcCgkbGlzdCk7CgogICAgZm9yZWFjaCgkbGlzdCBhcyAkbnVtYmVyKSB7CiAgICAgIGlmKCRudW1iZXIgPCAkcGl2b3QpIHsKICAgICAgICAkbFtdID0gJG51bWJlcjsKICAgICAgfQogICAgICBlbHNlIHsKICAgICAgICAkcltdID0gJG51bWJlcjsKICAgICAgfQogICAgfQoKICAgIGlmKGNvdW50KCRsKSA9PSAkcGl2b3QgLSAkbWluIC0gMSkgewogICAgICAvLyBvbmx5IDEgbWlzc2luZyBudW1iZXIgdXNlIGRpZmZlcmVuY2Ugb2Ygc3VtcwogICAgICBwcmludCBhcnJheV9zdW0ocmFuZ2UoJG1pbiwgJHBpdm90LTEpKSAtIGFycmF5X3N1bSgkbCkgLiAiXG4iOwogICAgfQogICAgZWxzZSBpZihjb3VudCgkbCkgPCAkcGl2b3Q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