3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function solution(&$A) { $n = sizeof($A); $result = 0; for ($i = 0; $i < $n - 1; $i++) { if ($A[$i] == $A[$i + 1]) $result = $result + 1; } $r = 0; for ($i = 0; $i < $n; $i++) { $count = 0; if ($i > 0) { if ($A[$i - 1] != $A[$i]) $count = $count + 1; else $count = $count - 1; } if ($i < $n - 1) { if ($A[$i + 1] != $A[$i]) $count = $count + 1; else $count = $count - 1; } $r = max($r, $count); } return $result + $r; } $A[0] = 1 $A[1] = 1 $A[2] = 0 $A[3] = 1 $A[4] = 0 $A[5] = 0 print_r(solution($A));
Output for 5.4.0 - 5.4.27
Parse error: syntax error, unexpected '$A' (T_VARIABLE) in /in/39Bfg on line 32
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_VARIABLE in /in/39Bfg on line 32
Process exited with code 255.