Tasks Details
easy
Find value that occurs in odd number of elements.
Task Score
22%
Correctness
40%
Performance
0%
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.
Copyright 2009–2024 by Codility Limited. All Rights Reserved. Unauthorized copying, publication or disclosure prohibited.
Solution
Programming language used PHP
Time spent on task 57 minutes
Notes
not defined yet
Task timeline
Code: 15:29:22 UTC,
java,
autosave
Code: 15:34:12 UTC,
php,
autosave
Code: 15:34:40 UTC,
php,
autosave
Code: 15:34:50 UTC,
php,
autosave
Code: 15:35:32 UTC,
php,
autosave
Code: 15:35:43 UTC,
php,
autosave
Code: 15:36:02 UTC,
php,
autosave
// 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;
}
Code: 15:36:17 UTC,
php,
autosave
// 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;
}
Code: 15:36:45 UTC,
php,
autosave
// 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;
}
Code: 15:37:29 UTC,
php,
autosave
// 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;
}
Code: 15:37:40 UTC,
php,
autosave
// 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;
}
Code: 15:38:10 UTC,
php,
autosave
// 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;
}
Code: 15:38:28 UTC,
php,
autosave
// 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;
}
Code: 15:38:41 UTC,
php,
autosave
// 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;
}
Code: 15:38:58 UTC,
php,
autosave
// 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;
}
Code: 15:39:38 UTC,
php,
autosave
// 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;
}
Code: 15:39:53 UTC,
php,
autosave
// 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;
}
Code: 15:40:15 UTC,
php,
autosave
// 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;
}
Code: 15:40:34 UTC,
php,
autosave
// 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;
}
Code: 15:40:45 UTC,
php,
autosave
// 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;
}
Code: 15:40:55 UTC,
php,
autosave
// 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;
}
Code: 15:41:10 UTC,
php,
autosave
// 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;
}
Code: 15:41:41 UTC,
php,
autosave
// 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;
}
Code: 15:41:56 UTC,
php,
verify,
result: Failed
// 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;
}
Analysis
expand all
Example tests
1.
0.004 s
RUNTIME ERROR,
tested program terminated with exit code 255
stderr:
PHP Parse error: syntax error, unexpected '{' in func.php on line 14 Parse error: syntax error, unexpected '{' in func.php on line 14
Code: 15:42:29 UTC,
php,
autosave
// 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;
}
Code: 15:42:41 UTC,
php,
verify,
result: Failed
// 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;
}
Analysis
expand all
Example tests
1.
0.004 s
WRONG ANSWER,
got 0 expected 7
stderr:
PHP Notice: Array to string conversion in func.php on line 25 Notice: Array to string conversion in func.php on line 25stdout:
Array
Code: 15:42:59 UTC,
php,
verify,
result: Failed
// 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;
}
Analysis
expand all
Example tests
1.
0.008 s
WRONG ANSWER,
got 0 expected 7
stdout:
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 ) )
Code: 15:43:52 UTC,
php,
autosave
// 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;
}
Code: 15:44:03 UTC,
php,
verify,
result: Failed
// 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;
}
Analysis
expand all
Example tests
1.
0.008 s
WRONG ANSWER,
got 0 expected 7
stderr:
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 ) )
Code: 15:45:47 UTC,
php,
autosave
// 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;
}
Code: 15:45:58 UTC,
php,
autosave
// 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;
}
Code: 15:47:17 UTC,
php,
autosave
// 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;
}
Code: 15:47:29 UTC,
php,
autosave
// 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;
}
Code: 15:47:39 UTC,
php,
autosave
// 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;
}
Code: 15:47:54 UTC,
php,
autosave
// 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;
}
Code: 15:49:33 UTC,
php,
autosave
// 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;
}
Code: 15:49:44 UTC,
php,
autosave
// 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;
}
Code: 15:50:11 UTC,
php,
autosave
// 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;
}
Code: 15:50:17 UTC,
php,
verify,
result: Failed
// 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;
}
Analysis
expand all
Example tests
1.
0.008 s
WRONG ANSWER,
got 0 expected 7
stderr:
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 ) )
Code: 15:51:55 UTC,
php,
autosave
// 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;
}
Code: 15:52:09 UTC,
php,
autosave
// 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;
}
Code: 15:52:12 UTC,
php,
verify,
result: Failed
// 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;
}
Analysis
expand all
Example tests
1.
0.004 s
WRONG ANSWER,
got 9 expected 7
stderr:
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
Code: 15:52:44 UTC,
php,
autosave
// 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;
}
Code: 15:52:50 UTC,
php,
verify,
result: Passed
// 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;
}
Analysis
Code: 15:53:36 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[1, 5, 4, 5, 4, 2, 4, 2]
Analysis
Code: 15:54:12 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[1, 5, 4, 5, 4, 2, 4, 2, 4]
Analysis
Code: 15:54:45 UTC,
php,
autosave
// 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;
}
Code: 15:54:47 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[1, 5, 4, 5, 4, 2, 4, 2, 4]
Analysis
expand all
Example tests
1.
0.004 s
OK
stdout:
Array ( [0] => Array ( [0] => 9 [1] => 0 ) [1] => Array ( [0] => 3 [1] => 0 ) )
expand all
User tests
1.
0.004 s
OK
function result: 2
function result: 2
stdout:
Array ( [0] => Array ( [0] => 1 [1] => 0 ) [1] => Array ( [0] => 5 [1] => 0 ) )
Code: 15:55:27 UTC,
php,
autosave
// 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;
}
Code: 15:55:58 UTC,
php,
autosave
// 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;
}
Code: 15:56:29 UTC,
php,
autosave
// 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;
}
Code: 15:56:34 UTC,
php,
verify,
result: Failed
// 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;
}
User test case 1:
[1, 5, 4, 5, 4, 2, 4, 2, 4]
Analysis
expand all
Example tests
1.
0.004 s
WRONG ANSWER,
got 0 expected 7
stdout:
Array ( [0] => Array ( [0] => 9 [1] => 0 ) [1] => Array ( [0] => 3 [1] => 0 ) )
expand all
User tests
1.
0.004 s
OK
function result: 0
function result: 0
stdout:
Array ( [0] => Array ( [0] => 1 [1] => 0 ) [1] => Array ( [0] => 5 [1] => 0 ) )
Code: 15:56:43 UTC,
php,
verify,
result: Failed
// 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;
}
User test case 1:
[1, 5, 4, 5, 4, 2, 4, 2, 4]
Analysis
expand all
Example tests
1.
0.004 s
WRONG ANSWER,
got 3 expected 7
stdout:
Array ( [0] => Array ( [0] => 9 [1] => 0 ) [1] => Array ( [0] => 3 [1] => 0 ) )
expand all
User tests
1.
0.004 s
OK
function result: 5
function result: 5
stdout:
Array ( [0] => Array ( [0] => 1 [1] => 0 ) [1] => Array ( [0] => 5 [1] => 0 ) )
Code: 15:57:19 UTC,
php,
autosave
// 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;
}
Code: 15:57:30 UTC,
php,
autosave
// 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;
}
Code: 15:58:03 UTC,
php,
autosave
// 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;
}
Code: 15:58:14 UTC,
php,
autosave
// 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;
}
Code: 15:58:19 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[1, 5, 4, 5, 4, 2, 4, 2, 4]
Analysis
expand all
Example tests
1.
0.008 s
OK
stdout:
Array ( [0] => Array ( [0] => 9 [1] => 0 ) [1] => Array ( [0] => 3 [1] => 0 ) [2] => Array ( [0] => 7 [1] => 0 ) )
expand all
User tests
1.
0.004 s
OK
function result: 2
function result: 2
stdout:
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 ) )
Code: 15:59:12 UTC,
php,
autosave
// 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;
}
Code: 15:59:25 UTC,
php,
autosave
// 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;
}
Code: 15:59:28 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[1, 5, 4, 5, 4, 2, 4, 2, 4]
Analysis
expand all
Example tests
1.
0.004 s
OK
stdout:
Array ( [0] => Array ( [0] => 9 [1] => 3 ) [1] => Array ( [0] => 3 [1] => 1 ) [2] => Array ( [0] => 7 [1] => 0 ) )
expand all
User tests
1.
0.004 s
OK
function result: 2
function result: 2
stdout:
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 ) )
Code: 16:03:02 UTC,
php,
autosave
// 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;
}
Code: 16:03:16 UTC,
php,
autosave
// 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;
}
Code: 16:03:30 UTC,
php,
autosave
// 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;
}
Code: 16:03:40 UTC,
php,
autosave
// 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;
}
Code: 16:03:47 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[1, 5, 4, 5, 4, 2, 4, 2, 4]
Analysis
expand all
Example tests
1.
0.008 s
OK
stdout:
Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 2 ) [2] => Array ( [0] => 7 [1] => 0 ) )
expand all
User tests
1.
0.008 s
OK
function result: 1
function result: 1
stdout:
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 ) )
Code: 16:04:52 UTC,
php,
autosave
// 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;
}
Code: 16:05:02 UTC,
php,
autosave
// 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;
}
Code: 16:05:02 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[1, 5, 4, 5, 4, 2, 4, 2, 4]
Analysis
Code: 16:05:43 UTC,
php,
autosave
// 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;
}
Code: 16:05:54 UTC,
php,
autosave
// 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;
}
Code: 16:06:00 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[1, 5, 4, 5, 4, 2, 4, 2, 4]
User test case 2:
[6, 7, 6, 8, 6, 8, 6]
Analysis
Code: 16:06:27 UTC,
php,
autosave
// 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;
}
Code: 16:06:38 UTC,
php,
autosave
// 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;
}
Code: 16:06:41 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[1, 5, 4, 5, 4, 2, 4, 2, 4]
User test case 2:
[6, 7, 6, 8, 6, 8, 6]
Analysis
expand all
Example tests
1.
0.004 s
OK
stdout:
Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 2 ) [2] => Array ( [0] => 7 [1] => 0 ) )
expand all
User tests
1.
0.004 s
OK
function result: 1
function result: 1
stdout:
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.
0.008 s
OK
function result: 0
function result: 0
stdout:
Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 2 ) [2] => Array ( [0] => 8 [1] => 1 ) )
Code: 16:11:24 UTC,
php,
autosave
// 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;
}
Code: 16:11:29 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[1, 5, 4, 5, 4, 2, 4, 2, 4]
User test case 2:
[6, 7, 6, 8, 6, 8, 6]
Analysis
expand all
Example tests
1.
0.008 s
OK
stdout:
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 ) )
expand all
User tests
1.
0.008 s
OK
function result: 1
function result: 1
stdout:
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 ( [
1.
0.008 s
OK
function result: 0
function result: 0
stdout:
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 ) )
Code: 16:11:38 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[6, 7, 6, 8, 6, 8, 6]
Analysis
expand all
Example tests
1.
0.008 s
OK
stdout:
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 ) )
expand all
User tests
1.
0.008 s
OK
function result: 0
function result: 0
stdout:
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 ) )
Code: 16:11:55 UTC,
php,
autosave
// 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;
}
Code: 16:12:14 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[6, 7, 6, 8, 6, 8, 6]
Analysis
expand all
Example tests
1.
0.008 s
OK
stdout:
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 ) )
expand all
User tests
1.
0.008 s
OK
function result: 0
function result: 0
stdout:
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 ) )
Code: 16:14:28 UTC,
php,
autosave
// 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;
}
Code: 16:14:46 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[6, 7, 6, 8, 6, 8, 6]
Analysis
expand all
Example tests
1.
0.008 s
OK
stdout:
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 ) )
expand all
User tests
1.
0.008 s
OK
function result: 7
function result: 7
stdout:
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 ) )
Code: 16:14:59 UTC,
php,
autosave
// 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;
}
Code: 16:14:59 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[6, 7, 6, 8, 6, 8, 6]
Analysis
Code: 16:15:26 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[6, 7, 6, 8, 6, 8, 6]
User test case 2:
[1, 4, 1, 4, 5]
Analysis
Code: 16:15:56 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[6, 7, 6, 8, 6, 8, 6]
User test case 2:
[1, 4, 1, 4, 5]
User test case 3:
[2]
User test case 4:
[1, 3, 1]
Analysis
expand all
User tests
1.
0.004 s
OK
function result: 7
function result: 7
1.
0.004 s
OK
function result: 5
function result: 5
1.
0.004 s
OK
function result: 2
function result: 2
1.
0.004 s
OK
function result: 3
function result: 3
Code: 16:16:19 UTC,
php,
autosave
// 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;
}
Code: 16:16:25 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[6, 7, 6, 8, 6, 8, 6]
User test case 2:
[1, 4, 1, 4, 5]
User test case 3:
[2]
User test case 4:
[1, 3, 1]
Analysis
expand all
Example tests
1.
0.004 s
OK
stdout:
Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 1 ) [2] => Array ( [0] => 7 [1] => 0 ) )
expand all
User tests
1.
0.004 s
OK
function result: 7
function result: 7
stdout:
Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 0 ) [2] => Array ( [0] => 8 [1] => 1 ) )
1.
0.004 s
OK
function result: 5
function result: 5
stdout:
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 4 [1] => 1 ) [2] => Array ( [0] => 5 [1] => 0 ) )
1.
0.004 s
OK
function result: 2
function result: 2
stdout:
Array ( [0] => Array ( [0] => 2 [1] => 0 ) )
1.
0.004 s
OK
function result: 3
function result: 3
stdout:
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 0 ) )
Code: 16:17:41 UTC,
php,
autosave
// 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;
}
Code: 16:17:54 UTC,
php,
verify,
result: Failed
// 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;
}
User test case 1:
[6, 7, 6, 8, 6, 8, 6]
User test case 2:
[1, 4, 1, 4, 5]
User test case 3:
[2]
User test case 4:
[1, 3, 1]
Analysis
expand all
Example tests
1.
0.008 s
WRONG ANSWER,
got 9 expected 7
stdout:
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 ) )
expand all
User tests
1.
0.004 s
OK
function result: 7
function result: 7
stdout:
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 ) )
1.
0.004 s
OK
function result: 5
function result: 5
stdout:
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 4 [1] => 1 ) [2] => Array ( [0] => 5 [1] => 0 ) )
1.
0.004 s
OK
function result: 2
function result: 2
stdout:
Array ( [0] => Array ( [0] => 2 [1] => 0 ) )
1.
0.004 s
OK
function result: 3
function result: 3
stdout:
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 0 ) )
Code: 16:18:16 UTC,
php,
autosave
// 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;
}
Code: 16:18:20 UTC,
php,
verify,
result: Failed
// 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;
}
User test case 1:
[6, 7, 6, 8, 6, 8, 6]
User test case 2:
[1, 4, 1, 4, 5]
User test case 3:
[2]
User test case 4:
[1, 3, 1]
Analysis
expand all
Example tests
1.
0.004 s
WRONG ANSWER,
got 9 expected 7
expand all
User tests
1.
0.004 s
OK
function result: 7
function result: 7
1.
0.004 s
OK
function result: 5
function result: 5
1.
0.004 s
OK
function result: 2
function result: 2
1.
0.004 s
OK
function result: 3
function result: 3
Code: 16:18:44 UTC,
php,
autosave
// 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;
}
Code: 16:18:46 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[6, 7, 6, 8, 6, 8, 6]
User test case 2:
[1, 4, 1, 4, 5]
User test case 3:
[2]
User test case 4:
[1, 3, 1]
Analysis
expand all
User tests
1.
0.004 s
OK
function result: 7
function result: 7
1.
0.004 s
OK
function result: 5
function result: 5
1.
0.004 s
OK
function result: 2
function result: 2
1.
0.004 s
OK
function result: 3
function result: 3
Code: 16:19:11 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[6, 7, 6, 8, 6, 8, 6]
User test case 2:
[1, 4, 1, 4, 5]
User test case 3:
[2]
User test case 4:
[1, 3, 1]
Analysis
expand all
Example tests
1.
0.008 s
OK
stdout:
Array ( [0] => Array ( [0] => 9 [1] => 2 ) [1] => Array ( [0] => 3 [1] => 1 ) [2] => Array ( [0] => 7 [1] => 0 ) )
expand all
User tests
1.
0.004 s
OK
function result: 7
function result: 7
stdout:
Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 0 ) [2] => Array ( [0] => 8 [1] => 1 ) )
1.
0.004 s
OK
function result: 5
function result: 5
stdout:
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 4 [1] => 1 ) [2] => Array ( [0] => 5 [1] => 0 ) )
1.
0.004 s
OK
function result: 2
function result: 2
stdout:
Array ( [0] => Array ( [0] => 2 [1] => 0 ) )
1.
0.004 s
OK
function result: 3
function result: 3
stdout:
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 0 ) )
Code: 16:19:47 UTC,
php,
autosave
// 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;
}
Code: 16:19:50 UTC,
php,
verify,
result: Failed
// 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;
}
User test case 1:
[6, 7, 6, 8, 6, 8, 6]
User test case 2:
[1, 4, 1, 4, 5]
User test case 3:
[2]
User test case 4:
[1, 3, 1]
Analysis
expand all
Example tests
1.
0.004 s
WRONG ANSWER,
got 9 expected 7
stdout:
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 ) )
expand all
User tests
1.
0.004 s
OK
function result: 7
function result: 7
stdout:
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 ) )
1.
0.004 s
OK
function result: 5
function result: 5
stdout:
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 4 [1] => 1 ) [2] => Array ( [0] => 5 [1] => 0 ) )
1.
0.004 s
OK
function result: 2
function result: 2
stdout:
Array ( [0] => Array ( [0] => 2 [1] => 0 ) )
1.
0.004 s
OK
function result: 3
function result: 3
stdout:
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 0 ) )
Code: 16:22:04 UTC,
php,
autosave
// 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;
}
Code: 16:22:22 UTC,
php,
autosave
// 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;
}
Code: 16:22:32 UTC,
php,
autosave
// 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;
}
Code: 16:22:43 UTC,
php,
autosave
// 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;
}
Code: 16:22:53 UTC,
php,
autosave
// 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;
}
Code: 16:23:08 UTC,
php,
autosave
// 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;
}
Code: 16:23:18 UTC,
php,
autosave
// 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;
}
Code: 16:23:40 UTC,
php,
autosave
// 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;
}
Code: 16:23:55 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[6, 7, 6, 8, 6, 8, 6]
User test case 2:
[1, 4, 1, 4, 5]
User test case 3:
[2]
User test case 4:
[1, 3, 1]
Analysis
expand all
Example tests
1.
0.004 s
OK
stdout:
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 ) )
expand all
User tests
1.
0.004 s
OK
function result: 7
function result: 7
stdout:
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 ) )
1.
0.004 s
OK
function result: 5
function result: 5
stdout:
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 4 [1] => 1 ) [2] => Array ( [0] => 5 [1] => 0 ) )
1.
0.004 s
OK
function result: 2
function result: 2
stdout:
Array ( [0] => Array ( [0] => 2 [1] => 0 ) )
1.
0.004 s
OK
function result: 3
function result: 3
stdout:
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 0 ) )
Code: 16:24:27 UTC,
php,
autosave
// 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;
}
Code: 16:24:31 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[6, 7, 6, 8, 6, 8, 6]
User test case 2:
[1, 4, 1, 4, 5]
User test case 3:
[2]
User test case 4:
[1, 3, 1]
Analysis
expand all
Example tests
1.
0.004 s
OK
stdout:
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 ) )
expand all
User tests
1.
0.004 s
OK
function result: 7
function result: 7
stdout:
Array ( [0] => Array ( [0] => 6 [1] => 1 ) [1] => Array ( [0] => 7 [1] => 0 ) [2] => Array ( [0] => 8 [1] => 1 ) )
1.
0.004 s
OK
function result: 5
function result: 5
stdout:
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 4 [1] => 1 ) [2] => Array ( [0] => 5 [1] => 0 ) )
1.
0.004 s
OK
function result: 2
function result: 2
stdout:
Array ( [0] => Array ( [0] => 2 [1] => 0 ) )
1.
0.004 s
OK
function result: 3
function result: 3
stdout:
Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 3 [1] => 0 ) )
Code: 16:24:51 UTC,
php,
autosave
// 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;
}
Code: 16:24:54 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[6, 7, 6, 8, 6, 8, 6]
User test case 2:
[1, 4, 1, 4, 5]
User test case 3:
[2]
User test case 4:
[1, 3, 1]
Analysis
expand all
User tests
1.
0.004 s
OK
function result: 7
function result: 7
1.
0.004 s
OK
function result: 5
function result: 5
1.
0.004 s
OK
function result: 2
function result: 2
1.
0.004 s
OK
function result: 3
function result: 3
Code: 16:25:30 UTC,
php,
verify,
result: Passed
// 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;
}
User test case 1:
[6, 7, 6, 8, 6, 8, 6]
User test case 2:
[1, 4, 1, 4, 5]
User test case 3:
[2]
User test case 4:
[1, 3, 1]
Analysis
expand all
User tests
1.
0.004 s
OK
function result: 7
function result: 7
1.
0.004 s
OK
function result: 5
function result: 5
1.
0.004 s
OK
function result: 2
function result: 2
1.
0.004 s
OK
function result: 3
function result: 3
Code: 16:25:33 UTC,
php,
final,
score: 
22
// 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;
}
Analysis summary
The following issues have been detected: wrong answers.
Analysis
expand all
Correctness tests
1.
0.004 s
OK
1.
0.004 s
WRONG ANSWER,
got 1 expected 4
1.
0.004 s
OK
1.
0.004 s
WRONG ANSWER,
got 23 expected 42
1.
0.004 s
WRONG ANSWER,
got 1411 expected 4242
expand all
Performance tests
1.
0.004 s
WRONG ANSWER,
got 1713 expected 100
1.
0.072 s
WRONG ANSWER,
got 1603513 expected 500000
1.
0.748 s
WRONG ANSWER,
got 386 expected 700
1.
0.788 s
WRONG ANSWER,
got 84967411 expected 500111222