Your browser is not supported. Please, update your browser or switch to a different one. Learn more about which browsers are supported.
Task description
A non-empty array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired.
For example, in array A such that:
A[0] = 9 A[1] = 3 A[2] = 9 A[3] = 3 A[4] = 9 A[5] = 7 A[6] = 9
- the elements at indexes 0 and 2 have value 9,
- the elements at indexes 1 and 3 have value 3,
- the elements at indexes 4 and 6 have value 9,
- the element at index 5 has value 7 and is unpaired.
Write a function:
function solution($A);
that, given an array A consisting of N integers fulfilling the above conditions, returns the value of the unpaired element.
For example, given array A such that:
A[0] = 9 A[1] = 3 A[2] = 9 A[3] = 3 A[4] = 9 A[5] = 7 A[6] = 9the function should return 7, as explained in the example above.
Write an efficient algorithm for the following assumptions:
- N is an odd integer within the range [1..1,000,000];
- each element of array A is an integer within the range [1..1,000,000,000];
- all but one of the values in A occur an even number of times.
Task timeline
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i])
}
$tmp[$idx] = {$A[$i], $cnt};
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i])
}
$tmp[$idx] = {$A[$i], $cnt};
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i]) $idx++;
}
$tmp[$idx] = {$A[$i], $cnt};
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i]) $idx++;
}
$tmp[$idx] = {$A[$i], $cnt};
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i]) $idx++;
else if ()
}
$tmp[$idx] = {$A[$i], $cnt};
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i]) $idx++;
else if ($i)
}
$tmp[$idx] = {$A[$i], $cnt};
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i]) $idx++;
else if ($i > 1) {
if ($A[$i])
}
}
$tmp[$idx] = {$A[$i], $cnt};
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i]) $idx++;
else if ($i > 1) {
if ($A[$i-2] == )
}
}
$tmp[$idx] = {$A[$i], $cnt};
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i]) $idx++;
else if ($i > 1) {
if ($A[$i-2] == $A[$i])
}
}
$tmp[$idx] = {$A[$i], $cnt};
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i]) $idx++;
else if ($i > 1) {
if ($A[$i-2] == $A[$i])
}
}
$tmp[$idx] = {$A[$i], $cnt};
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i]) $idx++;
else if ($i > 1) {
if ($A[$i-2] == $A[$i]) $idx--;
}
}
$tmp[$idx] = {$A[$i], $cnt};
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i]) $idx++;
else if ($i > 1) {
if ($A[$i-2] == $A[$i]) $idx--;
}
}
else $tmp[$idx] = {$A[$i], $cnt};
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i]) {
$idx++;
else if ($i > 1) {
if ($A[$i-2] == $A[$i]) $idx--;
}
}
else $tmp[$idx] = {$A[$i], $cnt};
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i]) {
$idx++;
}
else if ($i > 1) {
if ($A[$i-2] == $A[$i]) $idx--;
}
}
else $tmp[$idx] = {$A[$i], $cnt};
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i]) {
$idx++;
$tmp[$idx] = {$A[$i], $cnt};
}
else if ($i > 1) {
if ($A[$i-2] == $A[$i]) $idx--;
}
}
else $tmp[$idx] = {$A[$i], $cnt};
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i]) {
$idx++;
$tmp[$idx] = {$A[$i], $cnt};
}
else if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$idx--;
}
}
}
else $tmp[$idx] = {$A[$i], $cnt};
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i]) {
$idx++;
$tmp[$idx] = {$A[$i], $cnt};
}
else if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$idx--;
$tmp[$idx][1]++;
}
}
}
else $tmp[$idx] = {$A[$i], $cnt};
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i]) {
$idx++;
$tmp[$idx] = {$A[$i], $cnt};
}
else if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$idx--;
$tmp[$idx][1]++;
}
}
}
else $tmp[$idx] = {$A[$i], $cnt};
}
print $tmp;
return $rs;
}
PHP Parse error: syntax error, unexpected '{' in func.php on line 14 Parse error: syntax error, unexpected '{' in func.php on line 14
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i]) {
$idx++;
$tmp[$idx] = $A[$i], $cnt};
}
else if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$idx--;
$tmp[$idx][1]++;
}
}
}
else $tmp[$idx] = {$A[$i], $cnt};
}
print $tmp;
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i]) {
$idx++;
$tmp[$idx] = array($A[$i], $cnt);
}
else if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$idx--;
$tmp[$idx][1]++;
}
}
}
else $tmp[$idx] = array($A[$i], $cnt);
}
print $tmp;
return $rs;
}
PHP Notice: Array to string conversion in func.php on line 25 Notice: Array to string conversion in func.php on line 25stdout:
Array
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i]) {
$idx++;
$tmp[$idx] = array($A[$i], $cnt);
}
else if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$idx--;
$tmp[$idx][1]++;
}
}
}
else $tmp[$idx] = array($A[$i], $cnt);
}
print_r($tmp);
return $rs;
}
Array ( [0] => Array ( [0] => 9 [1] => 0 ) [1] => Array ( [0] => 3 [1] => 0 ) [2] => Array ( [0] => 9 [1] => 0 ) [3] => Array ( [0] => 3 [1] => 0 ) [4] => Array ( [0] => 9 [1] => 0 ) [5] => Array ( [0] => 7 [1] => 0 ) [6] => Array ( [0] => 9 [1] => 0 ) )
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($A[$i-1] != $A[$i]) {
$idx++;
$tmp[$idx] = array($A[$i], $cnt);
}
else
}
else $tmp[$idx] = array($A[$i], $cnt);
}
print_r($tmp);
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$idx--;
$tmp[$idx][1]++;
}
}
else if ($A[$i-1] != $A[$i]) {
$idx++;
$tmp[$idx] = array($A[$i], $cnt);
}
}
else $tmp[$idx] = array($A[$i], $cnt);
}
print_r($tmp);
return $rs;
}
PHP Notice: Undefined offset: -1 in func.php on line 15 Notice: Undefined offset: -1 in func.php on line 15 PHP Notice: Undefined offset: 1 in func.php on line 15 Notice: Undefined offset: 1 in func.php on line 15 PHP Notice: Undefined offset: -2 in func.php on line 15 Notice: Undefined offset: -2 in func.php on line 15 PHP Notice: Undefined offset: 1 in func.php on line 15 Notice: Undefined offset: 1 in func.php on line 15 PHP Notice: Undefined offset: -3 in func.php on line 15 Notice: Undefined offset: -3 in func.php on line 15 PHP Notice: Undefined offset: 1 in func.php on line 15 Notice: Undefined offset: 1 in func.php on line 15stdout:
Array ( [0] => Array ( [0] => 9 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 0 ) [-1] => Array ( [1] => 1 ) [-2] => Array ( [1] => 1 ) [-3] => Array ( [1] => 1 ) )
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$idx--;
$tmp[$idx][1]++;
}
el
}
else if ($A[$i-1] != $A[$i]) {
$idx++;
$tmp[$idx] = array($A[$i], $cnt);
}
}
else $tmp[$idx] = array($A[$i], $cnt);
}
print_r($tmp);
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 0) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$idx--;
$tmp[$idx][1]++;
}
else {
}
}
else if ($A[$i-1] != $A[$i]) {
$idx++;
$tmp[$idx] = array($A[$i], $cnt);
}
}
else $tmp[$idx] = array($A[$i], $cnt);
}
print_r($tmp);
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$idx--;
$tmp[$idx][1]++;
}
else {
}
}
else if ($A[$i-1] != $A[$i]) {
$idx++;
$tmp[$idx] = array($A[$i], $cnt);
}
}
else $tmp[$idx] = array($A[$i], $cnt);
}
print_r($tmp);
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$idx--;
$tmp[$idx][1]++;
}
else {
}
}
else if ($A[$i-1] != $A[$i]) {
$idx++;
$tmp[$idx] = array($A[$i], $cnt);
}
}
else $tmp[$idx+$i] = array($A[$i], $cnt);
}
print_r($tmp);
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$idx--;
$tmp[$idx][1]++;
}
else {
}
}
}
else $tmp[$idx+$i] = array($A[$i], $cnt);
}
print_r($tmp);
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$idx--;
$tmp[$idx][1]++;
}
}
else $tmp[$idx+$i] = array($A[$i], $cnt);
}
print_r($tmp);
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$idx--;
$tmp[$idx][1]++;
}
}
else $tmp[$idx+$i] = array($A[$i], $cnt);
}
print_r($tmp);
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$idx--;
$tmp[$idx][1]++;
}
}
else $tmp[$idx+$i] = array($A[$i], $cnt);
}
print_r($tmp);
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$max--;
$tmp[$max][1]++;
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$max--;
$tmp[$max][1]++;
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
return $rs;
}
PHP Notice: Undefined offset: -1 in func.php on line 14 Notice: Undefined offset: -1 in func.php on line 14 PHP Notice: Undefined offset: 1 in func.php on line 14 Notice: Undefined offset: 1 in func.php on line 14 PHP Notice: Undefined offset: -2 in func.php on line 14 Notice: Undefined offset: -2 in func.php on line 14 PHP Notice: Undefined offset: 1 in func.php on line 14 Notice: Undefined offset: 1 in func.php on line 14 PHP Notice: Undefined offset: -3 in func.php on line 14 Notice: Undefined offset: -3 in func.php on line 14 PHP Notice: Undefined offset: 1 in func.php on line 14 Notice: Undefined offset: 1 in func.php on line 14stdout:
Array ( [0] => Array ( [0] => 9 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 0 ) [-1] => Array ( [1] => 1 ) [-2] => Array ( [1] => 1 ) [-3] => Array ( [1] => 1 ) )
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$max--;
$tmp[$max][1]++;
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$max--;
$tmp[$max][1]++;
}
$rs = $A[$i];
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$max--;
$tmp[$max][1]++;
}
$rs = $A[$i];
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
// print_r($tmp);
return $rs;
}
PHP Notice: Undefined offset: -1 in func.php on line 14 Notice: Undefined offset: -1 in func.php on line 14 PHP Notice: Undefined offset: 1 in func.php on line 14 Notice: Undefined offset: 1 in func.php on line 14 PHP Notice: Undefined offset: -2 in func.php on line 14 Notice: Undefined offset: -2 in func.php on line 14 PHP Notice: Undefined offset: 1 in func.php on line 14 Notice: Undefined offset: 1 in func.php on line 14 PHP Notice: Undefined offset: -3 in func.php on line 14 Notice: Undefined offset: -3 in func.php on line 14 PHP Notice: Undefined offset: 1 in func.php on line 14 Notice: Undefined offset: 1 in func.php on line 14
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
}
$rs = $A[$i];
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
// print_r($tmp);
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
continue;
}
$rs = $A[$i];
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
// print_r($tmp);
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
continue;
}
$rs = $A[$i];
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
// print_r($tmp);
return $rs;
}
[1, 5, 4, 5, 4, 2, 4, 2]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
continue;
}
$rs = $A[$i];
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
// print_r($tmp);
return $rs;
}
[1, 5, 4, 5, 4, 2, 4, 2, 4]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
continue;
}
$rs = $A[$i];
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
continue;
}
$rs = $A[$i];
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
return $rs;
}
Array ( [0] => Array ( [0] => 9 [1] => 0 ) [1] => Array ( [0] => 3 [1] => 0 ) )
function result: 2
Array ( [0] => Array ( [0] => 1 [1] => 0 ) [1] => Array ( [0] => 5 [1] => 0 ) )
[1, 5, 4, 5, 4, 2, 4, 2, 4]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
continue;
}
$rs = $A[$i];
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
continue;
}
$rs = $A[$i];
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
continue;
}
$rs = $A[$i];
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[]
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
continue;
}
$rs = $A[$i];
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][1];
}
return $rs;
}
Array ( [0] => Array ( [0] => 9 [1] => 0 ) [1] => Array ( [0] => 3 [1] => 0 ) )
function result: 0
Array ( [0] => Array ( [0] => 1 [1] => 0 ) [1] => Array ( [0] => 5 [1] => 0 ) )
[1, 5, 4, 5, 4, 2, 4, 2, 4]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
continue;
}
$rs = $A[$i];
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
Array ( [0] => Array ( [0] => 9 [1] => 0 ) [1] => Array ( [0] => 3 [1] => 0 ) )
function result: 5
Array ( [0] => Array ( [0] => 1 [1] => 0 ) [1] => Array ( [0] => 5 [1] => 0 ) )
[1, 5, 4, 5, 4, 2, 4, 2, 4]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
continue;
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
continue;
}
else {
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
continue;
}
else {
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
continue;
}
else {
$max++;
$tmp[$max]
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
continue;
}
else {
$max++;
$tmp[$max] = array($A[$i], $cnt);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
Array ( [0] => Array ( [0] => 9 [1] => 0 ) [1] => Array ( [0] => 3 [1] => 0 ) [2] => Array ( [0] => 7 [1] => 0 ) )
function result: 2
Array ( [0] => Array ( [0] => 1 [1] => 0 ) [1] => Array ( [0] => 5 [1] => 0 ) [2] => Array ( [0] => 4 [1] => 0 ) [3] => Array ( [0] => 2 [1] => 0 ) )
[1, 5, 4, 5, 4, 2, 4, 2, 4]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
cont
}
else {
$max++;
$tmp[$max] = array($A[$i], $cnt);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], $cnt);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
$tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], $cnt);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
Array ( [0] => Array ( [0] => 9 [1] => 3 ) [1] => Array ( [0] => 3 [1] => 1 ) [2] => Array ( [0] => 7 [1] => 0 ) )
function result: 2
Array ( [0] => Array ( [0] => 1 [1] => 0 ) [1] => Array ( [0] => 5 [1] => 2 ) [2] => Array ( [0] => 4 [1] => 3 ) [3] => Array ( [0] => 2 [1] => 0 ) )
[1, 5, 4, 5, 4, 2, 4, 2, 4]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if$tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], $cnt);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], $cnt);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i])$tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], $cnt);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max-1][1]++;
else
}
else {
$max++;
$tmp[$max] = array($A[$i], $cnt);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], $cnt);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 2 ) [2] => Array ( [0] => 7 [1] => 0 ) )
function result: 1
Array ( [0] => Array ( [0] => 1 [1] => 0 ) [1] => Array ( [0] => 5 [1] => 1 ) [2] => Array ( [0] => 4 [1] => 3 ) [3] => Array ( [0] => 2 [1] => 1 ) )
[1, 5, 4, 5, 4, 2, 4, 2, 4]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], $cnt);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], $cnt);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], $cnt);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
[1, 5, 4, 5, 4, 2, 4, 2, 4]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], $cn);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], $cnt);
}
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
$cnt = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
[1, 5, 4, 5, 4, 2, 4, 2, 4]
[6, 7, 6, 8, 6, 8, 6]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 2 ) [2] => Array ( [0] => 7 [1] => 0 ) )
function result: 1
Array ( [0] => Array ( [0] => 1 [1] => 0 ) [1] => Array ( [0] => 5 [1] => 1 ) [2] => Array ( [0] => 4 [1] => 3 ) [3] => Array ( [0] => 2 [1] => 1 ) )
function result: 0
Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 2 ) [2] => Array ( [0] => 8 [1] => 1 ) )
[1, 5, 4, 5, 4, 2, 4, 2, 4]
[6, 7, 6, 8, 6, 8, 6]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
print_r($tmp);
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
Array ( [0] => Array ( [0] => 9 [1] => 0 ) ) Array ( [0] => Array ( [0] => 9 [1] => 0 ) [1] => Array ( [0] => 3 [1] => 0 ) ) Array ( [0] => Array ( [0] => 9 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 0 ) ) Array ( [0] => Array ( [0] => 9 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 1 ) ) Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 1 ) ) Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 1 ) [2] => Array ( [0] => 7 [1] => 0 ) ) Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 2 ) [2] => Array ( [0] => 7 [1] => 0 ) )
function result: 1
Array ( [0] => Array ( [0] => 1 [1] => 0 ) ) Array ( [0] => Array ( [0] => 1 [1] => 0 ) [1] => Array ( [0] => 5 [1] => 0 ) ) Array ( [0] => Array ( [0] => 1 [1] => 0 ) [1] => Array ( [0] => 5 [1] => 0 ) [2] => Array ( [0] => 4 [1] => 0 ) ) Array ( [0] => Array ( [0] => 1 [1] => 0 ) [1] => Array ( [0] => 5 [1] => 1 ) [2] => Array ( [0] => 4 [1] => 0 ) ) Array ( [0] => Array ( [0] => 1 [1] => 0 ) [1] => Array ( [0] => 5 [1] => 1 ) [2] => Array ( [0] => 4 [1] => 1 ) ) Array ( [0] => Array ( [0] => 1 [1] => 0 ) [1] => Array ( [0] => 5 [1] => 1 ) [2] => Array ( [0] => 4 [1] => 1 ) [3] => Array ( [0] => 2 [1] => 0 ) ) Array ( [0] => Array ( [0] => 1 [1] => 0 ) [1] => Array ( [0] => 5 [1] => 1 ) [2] => Array ( [0] => 4 [1] => 2 ) [3] => Array ( [0] => 2 [1] => 0 ) ) Array ( [0] => Array ( [0] => 1 [1] => 0 ) [1] => Array ( [0] => 5 [1] => 1 ) [2] => Array ( [0] => 4 [1] => 2 ) [3] => Array ( [0] => 2 [1] => 1 ) ) Array ( [0] => Array ( [
function result: 0
Array ( [0] => Array ( [0] => 6 [1] => 0 ) ) Array ( [0] => Array ( [0] => 6 [1] => 0 ) [1] => Array ( [0] => 7 [1] => 0 ) ) Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 0 ) ) Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 0 ) [2] => Array ( [0] => 8 [1] => 0 ) ) Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 1 ) [2] => Array ( [0] => 8 [1] => 0 ) ) Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 1 ) [2] => Array ( [0] => 8 [1] => 1 ) ) Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 2 ) [2] => Array ( [0] => 8 [1] => 1 ) )
[1, 5, 4, 5, 4, 2, 4, 2, 4]
[6, 7, 6, 8, 6, 8, 6]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
print_r($tmp);
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
Array ( [0] => Array ( [0] => 9 [1] => 0 ) ) Array ( [0] => Array ( [0] => 9 [1] => 0 ) [1] => Array ( [0] => 3 [1] => 0 ) ) Array ( [0] => Array ( [0] => 9 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 0 ) ) Array ( [0] => Array ( [0] => 9 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 1 ) ) Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 1 ) ) Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 1 ) [2] => Array ( [0] => 7 [1] => 0 ) ) Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 2 ) [2] => Array ( [0] => 7 [1] => 0 ) )
function result: 0
Array ( [0] => Array ( [0] => 6 [1] => 0 ) ) Array ( [0] => Array ( [0] => 6 [1] => 0 ) [1] => Array ( [0] => 7 [1] => 0 ) ) Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 0 ) ) Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 0 ) [2] => Array ( [0] => 8 [1] => 0 ) ) Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 1 ) [2] => Array ( [0] => 8 [1] => 0 ) ) Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 1 ) [2] => Array ( [0] => 8 [1] => 1 ) ) Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 2 ) [2] => Array ( [0] => 8 [1] => 1 ) )
[6, 7, 6, 8, 6, 8, 6]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
prinprint_r($tmp);
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
print "i: ".$i." "; print_r($tmp);
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
i: 0 Array ( [0] => Array ( [0] => 9 [1] => 0 ) ) i: 1 Array ( [0] => Array ( [0] => 9 [1] => 0 ) [1] => Array ( [0] => 3 [1] => 0 ) ) i: 2 Array ( [0] => Array ( [0] => 9 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 0 ) ) i: 3 Array ( [0] => Array ( [0] => 9 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 1 ) ) i: 4 Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 1 ) ) i: 5 Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 1 ) [2] => Array ( [0] => 7 [1] => 0 ) ) i: 6 Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 2 ) [2] => Array ( [0] => 7 [1] => 0 ) )
function result: 0
i: 0 Array ( [0] => Array ( [0] => 6 [1] => 0 ) ) i: 1 Array ( [0] => Array ( [0] => 6 [1] => 0 ) [1] => Array ( [0] => 7 [1] => 0 ) ) i: 2 Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 0 ) ) i: 3 Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 0 ) [2] => Array ( [0] => 8 [1] => 0 ) ) i: 4 Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 1 ) [2] => Array ( [0] => 8 [1] => 0 ) ) i: 5 Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 1 ) [2] => Array ( [0] => 8 [1] => 1 ) ) i: 6 Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 2 ) [2] => Array ( [0] => 8 [1] => 1 ) )
[6, 7, 6, 8, 6, 8, 6]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else if$tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
print "i: ".$i." "; print_r($tmp);
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
print "i: ".$i." "; print_r($tmp);
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
i: 0 Array ( [0] => Array ( [0] => 9 [1] => 0 ) ) i: 1 Array ( [0] => Array ( [0] => 9 [1] => 0 ) [1] => Array ( [0] => 3 [1] => 0 ) ) i: 2 Array ( [0] => Array ( [0] => 9 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 0 ) ) i: 3 Array ( [0] => Array ( [0] => 9 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 1 ) ) i: 4 Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 1 ) ) i: 5 Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 1 ) [2] => Array ( [0] => 7 [1] => 0 ) ) i: 6 Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 1 ) [2] => Array ( [0] => 7 [1] => 0 ) )
function result: 7
i: 0 Array ( [0] => Array ( [0] => 6 [1] => 0 ) ) i: 1 Array ( [0] => Array ( [0] => 6 [1] => 0 ) [1] => Array ( [0] => 7 [1] => 0 ) ) i: 2 Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 0 ) ) i: 3 Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 0 ) [2] => Array ( [0] => 8 [1] => 0 ) ) i: 4 Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 0 ) [2] => Array ( [0] => 8 [1] => 0 ) ) i: 5 Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 0 ) [2] => Array ( [0] => 8 [1] => 1 ) ) i: 6 Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 0 ) [2] => Array ( [0] => 8 [1] => 1 ) )
[6, 7, 6, 8, 6, 8, 6]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
[6, 7, 6, 8, 6, 8, 6]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
[6, 7, 6, 8, 6, 8, 6]
[1, 4, 1, 4, 5]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
function result: 7
function result: 5
function result: 2
function result: 3
[6, 7, 6, 8, 6, 8, 6]
[1, 4, 1, 4, 5]
[2]
[1, 3, 1]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 1 ) [2] => Array ( [0] => 7 [1] => 0 ) )
function result: 7
Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 0 ) [2] => Array ( [0] => 8 [1] => 1 ) )
function result: 5
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 4 [1] => 1 ) [2] => Array ( [0] => 5 [1] => 0 ) )
function result: 2
Array ( [0] => Array ( [0] => 2 [1] => 0 ) )
function result: 3
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 0 ) )
[6, 7, 6, 8, 6, 8, 6]
[1, 4, 1, 4, 5]
[2]
[1, 3, 1]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print_r($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 1 ) [2] => Array ( [0] => 7 [1] => 0 ) [3] => Array ( [0] => 9 [1] => 0 ) )
function result: 7
Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 0 ) [2] => Array ( [0] => 8 [1] => 1 ) [3] => Array ( [0] => 6 [1] => 1 ) )
function result: 5
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 4 [1] => 1 ) [2] => Array ( [0] => 5 [1] => 0 ) )
function result: 2
Array ( [0] => Array ( [0] => 2 [1] => 0 ) )
function result: 3
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 0 ) )
[6, 7, 6, 8, 6, 8, 6]
[1, 4, 1, 4, 5]
[2]
[1, 3, 1]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
function result: 7
function result: 5
function result: 2
function result: 3
[6, 7, 6, 8, 6, 8, 6]
[1, 4, 1, 4, 5]
[2]
[1, 3, 1]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
/*else {
$max++;
$tmp[$max] = array($A[$i], 0);
}*/
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
/*else {
$max++;
$tmp[$max] = array($A[$i], 0);
}*/
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
function result: 7
function result: 5
function result: 2
function result: 3
[6, 7, 6, 8, 6, 8, 6]
[1, 4, 1, 4, 5]
[2]
[1, 3, 1]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
/*else {
$max++;
$tmp[$max] = array($A[$i], 0);
}*/
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print_R($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 1 ) [2] => Array ( [0] => 7 [1] => 0 ) )
function result: 7
Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 0 ) [2] => Array ( [0] => 8 [1] => 1 ) )
function result: 5
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 4 [1] => 1 ) [2] => Array ( [0] => 5 [1] => 0 ) )
function result: 2
Array ( [0] => Array ( [0] => 2 [1] => 0 ) )
function result: 3
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 0 ) )
[6, 7, 6, 8, 6, 8, 6]
[1, 4, 1, 4, 5]
[2]
[1, 3, 1]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}*/
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print_R($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) $tmp[$max][1]++;
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print_R($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 1 ) [2] => Array ( [0] => 7 [1] => 0 ) [3] => Array ( [0] => 9 [1] => 0 ) )
function result: 7
Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 0 ) [2] => Array ( [0] => 8 [1] => 1 ) [3] => Array ( [0] => 6 [1] => 1 ) )
function result: 5
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 4 [1] => 1 ) [2] => Array ( [0] => 5 [1] => 0 ) )
function result: 2
Array ( [0] => Array ( [0] => 2 [1] => 0 ) )
function result: 3
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 0 ) )
[6, 7, 6, 8, 6, 8, 6]
[1, 4, 1, 4, 5]
[2]
[1, 3, 1]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) {$tmp[$max][1]++;
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print_R($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) {
if ($tmp[$max][])
$tmp[$max][1]++;
}
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print_R($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) {
if ($tmp[$max][1])
$tmp[$max][1]++;
}
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print_R($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) {
if ($tmp[$max][1] < 1)
$tmp[$max][1]++;
}
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print_R($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) {
if ($tmp[$max][1] < 1) $tmp[$max][1]++;
}
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print_R($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) {
if ($tmp[$max][1] < 1) $tmp[$max][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print_R($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) {
if ($tmp[$max][1] < 1) $tmp[$max][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else if ($tmp[$max-1][0] == $A[$i]) $tmp[$max-1][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print_R($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) {
if ($tmp[$max][1] < 1) $tmp[$max][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else if ($tmp[$max-1][0] == $A[$i]) {
if ($tmp[$max-1][$tmp[$max-1][1]++;
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print_R($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) {
if ($tmp[$max][1] < 1) $tmp[$max][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else if ($tmp[$max-1][0] == $A[$i]) {
if ($tmp[$max-1][1] < 1) $tmp[$max-1][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print_R($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
Array ( [0] => Array ( [0] => 9 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 1 ) [2] => Array ( [0] => 9 [1] => 1 ) [3] => Array ( [0] => 7 [1] => 0 ) )
function result: 7
Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 0 ) [2] => Array ( [0] => 8 [1] => 1 ) [3] => Array ( [0] => 6 [1] => 1 ) )
function result: 5
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 4 [1] => 1 ) [2] => Array ( [0] => 5 [1] => 0 ) )
function result: 2
Array ( [0] => Array ( [0] => 2 [1] => 0 ) )
function result: 3
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 0 ) )
[6, 7, 6, 8, 6, 8, 6]
[1, 4, 1, 4, 5]
[2]
[1, 3, 1]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) {
if ($tmp[$max][1] < 1) $tmp[$max][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else if ($tmp[$max-1][0] == $A[$i]) {
if ($tmp[$max-1][1] < 1) $tmp[$max-1][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
/else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print_R($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) {
if ($tmp[$max][1] < 1) $tmp[$max][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else if ($tmp[$max-1][0] == $A[$i]) {
if ($tmp[$max-1][1] < 1) $tmp[$max-1][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
/*else {
$max++;
$tmp[$max] = array($A[$i], 0);
}*/
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print_R($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
Array ( [0] => Array ( [0] => 9 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 1 ) [2] => Array ( [0] => 9 [1] => 1 ) [3] => Array ( [0] => 7 [1] => 0 ) )
function result: 7
Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 0 ) [2] => Array ( [0] => 8 [1] => 1 ) )
function result: 5
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 4 [1] => 1 ) [2] => Array ( [0] => 5 [1] => 0 ) )
function result: 2
Array ( [0] => Array ( [0] => 2 [1] => 0 ) )
function result: 3
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 0 ) )
[6, 7, 6, 8, 6, 8, 6]
[1, 4, 1, 4, 5]
[2]
[1, 3, 1]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) {
if ($tmp[$max][1] < 1) $tmp[$max][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else if ($tmp[$max-1][0] == $A[$i]) {
if ($tmp[$max-1][1] < 1) $tmp[$max-1][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
print_R($tmp);
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) {
if ($tmp[$max][1] < 1) $tmp[$max][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else if ($tmp[$max-1][0] == $A[$i]) {
if ($tmp[$max-1][1] < 1) $tmp[$max-1][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
function result: 7
function result: 5
function result: 2
function result: 3
[6, 7, 6, 8, 6, 8, 6]
[1, 4, 1, 4, 5]
[2]
[1, 3, 1]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) {
if ($tmp[$max][1] < 1) $tmp[$max][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else if ($tmp[$max-1][0] == $A[$i]) {
if ($tmp[$max-1][1] < 1) $tmp[$max-1][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
function result: 7
function result: 5
function result: 2
function result: 3
[6, 7, 6, 8, 6, 8, 6]
[1, 4, 1, 4, 5]
[2]
[1, 3, 1]
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A) {
$rs = 0;
$tmp = array();
$idx = $max = 0;
for ($i = 0 ; $i < sizeof($A) ; $i++) {
if ($i > 1) {
if ($A[$i-2] == $A[$i]) {
if ($tmp[$max][0] == $A[$i]) {
if ($tmp[$max][1] < 1) $tmp[$max][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else if ($tmp[$max-1][0] == $A[$i]) {
if ($tmp[$max-1][1] < 1) $tmp[$max-1][1]++;
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max++;
$tmp[$max] = array($A[$i], 0);
}
}
else {
$max = $idx+$i;
$tmp[$max] = array($A[$i], 0);
}
}
for ($i = 0 ; $i < sizeof($tmp) ; $i++) {
if ($tmp[$i][1] == 0) $rs = $tmp[$i][0];
}
return $rs;
}
The following issues have been detected: wrong answers.