Skip to content

Instantly share code, notes, and snippets.

@rummykhan
Created January 24, 2019 08:25
Show Gist options
  • Save rummykhan/9bb12522cd1c26a778ee207f336ae62e to your computer and use it in GitHub Desktop.
Save rummykhan/9bb12522cd1c26a778ee207f336ae62e to your computer and use it in GitHub Desktop.
<?php
$a = [1, 2, 3, 4, 6, 7];
sort($a);
if ($a[0] != 1) {
return 0;
}
if ($a[0] < 1) {
return 0;
}
$supposed = $a[0] + (count($a) - 1);
$isMissing = $supposed != $a[count($a) - 1];
return $isMissing ? 0 : 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment