3v4l.org

run code in 300+ PHP versions simultaneously
<?php function solution($A) { // write your code in PHP5 $result = -1; $n = count($A); if ($n > 0) { if (0 && max($A) == $A[$n-1]) { $result = $n-1; } else { $center = round($n/2); while($center >1 && $center < $n){ $left = array_slice($A, 0, $center); $right = array_slice($A, $center); if (max($left) <= $A[$center]) { if (min($right) >= $A[$center]) { $result = $center; break; } else { $center = round(($center + $n - 1)/2); } } else { $center = round($center/2); } } } } return $result; } $A[0] = 4 ; $A[1] = 2 ; $A[2] = 2; $A[3] = 3 ; $A[4] = 1 ; $A[5] = 4; $A[6] = 7 ; $A[7] = 8 ; $A[8] = 6; $A[9] = 9; print_r(solution($A));

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.40.0080.00818.79
8.3.30.0100.00619.08
8.3.20.0090.00020.33
8.3.10.0040.00422.09
8.3.00.0040.00722.51
8.2.170.0070.00722.96
8.2.160.0100.00719.13
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0080.00019.61
8.2.110.0080.00320.53
8.2.100.0040.00817.84
8.2.90.0020.00519.35
8.2.80.0050.00318.05
8.2.70.0000.00817.75
8.2.60.0000.00817.93
8.2.50.0000.00818.07
8.2.40.0030.00518.16
8.2.30.0070.00018.10
8.2.20.0050.00217.70
8.2.10.0040.00417.79
8.2.00.0000.00817.82
8.1.270.0030.00522.09
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0000.01023.73
8.1.230.0080.00321.04
8.1.220.0050.00317.74
8.1.210.0050.00318.77
8.1.200.0060.00317.22
8.1.190.0040.00417.63
8.1.180.0040.00718.10
8.1.170.0040.00418.46
8.1.160.0040.00422.01
8.1.150.0000.00718.63
8.1.140.0000.00717.37
8.1.130.0030.00317.74
8.1.120.0040.00417.43
8.1.110.0040.00417.45
8.1.100.0040.00417.49
8.1.90.0040.00317.42
8.1.80.0000.00717.36
8.1.70.0030.00317.42
8.1.60.0090.00017.53
8.1.50.0000.00817.43
8.1.40.0000.00717.49
8.1.30.0000.00817.54
8.1.20.0000.00817.69
8.1.10.0050.00217.56
8.1.00.0030.00617.52
8.0.300.0000.00718.77
8.0.290.0000.00717.17
8.0.280.0000.00718.39
8.0.270.0040.00417.18
8.0.260.0030.00316.88
8.0.250.0000.00716.90
8.0.240.0040.00417.02
8.0.230.0070.00016.91
8.0.220.0040.00416.86
8.0.210.0030.00316.99
8.0.200.0000.00617.00
8.0.190.0040.00417.01
8.0.180.0040.00416.94
8.0.170.0030.00616.97
8.0.160.0000.00817.02
8.0.150.0030.00316.85
8.0.140.0030.00316.80
8.0.130.0060.00013.43
8.0.120.0040.00416.92
8.0.110.0040.00416.84
8.0.100.0040.00416.93
8.0.90.0040.00416.85
8.0.80.0080.00816.94
8.0.70.0000.00716.98
8.0.60.0030.00317.00
8.0.50.0040.00416.77
8.0.30.0060.01217.08
8.0.20.0060.01217.40
8.0.10.0040.00417.11
8.0.00.0080.01416.73
7.4.330.0060.00015.02
7.4.320.0030.00316.64
7.4.300.0030.00316.50
7.4.290.0030.00316.60
7.4.280.0000.00716.57
7.4.270.0030.00316.45
7.4.260.0110.00016.43
7.4.250.0030.00316.57
7.4.240.0040.00316.54
7.4.230.0030.00316.34
7.4.220.0100.01716.55
7.4.210.0060.01216.61
7.4.200.0070.00016.39
7.4.190.0070.00016.48
7.4.160.0110.00616.52
7.4.150.0170.00317.40
7.4.140.0110.00917.86
7.4.130.0040.01316.53
7.4.120.0090.00816.46
7.4.110.0160.00316.45
7.4.100.0090.00916.37
7.4.90.0110.01416.55
7.4.80.0100.00819.39
7.4.70.0110.00716.48
7.4.60.0120.01216.55
7.4.50.0000.00416.33
7.4.40.0100.00722.77
7.4.30.0130.00316.67
7.4.00.0070.00914.92
7.3.330.0000.00513.45
7.3.320.0000.00513.39
7.3.310.0040.00416.24
7.3.300.0040.00416.29
7.3.290.0090.00916.38
7.3.280.0100.00616.39
7.3.270.0090.00917.40
7.3.260.0110.00616.41
7.3.250.0100.00916.52
7.3.240.0070.01016.43
7.3.230.0120.00916.44
7.3.210.0060.01016.59
7.3.200.0040.01319.39
7.3.190.0100.00716.66
7.3.180.0090.00916.35
7.3.170.0080.00816.56
7.3.160.0130.00416.34
7.3.120.0020.01414.83
7.3.110.0060.00814.63
7.3.100.0060.01314.93
7.3.90.0070.00714.89
7.3.80.0090.00914.88
7.3.70.0070.01014.57
7.3.60.0030.00714.93
7.3.50.0140.00014.85
7.3.40.0030.01014.70
7.3.30.0090.00614.89
7.3.20.0000.01616.70
7.3.10.0060.00616.64
7.3.00.0070.00616.65
7.2.330.0070.01116.85
7.2.320.0160.00316.66
7.2.310.0070.01016.70
7.2.300.0070.01016.68
7.2.290.0140.00316.55
7.2.250.0040.01415.22
7.2.240.0080.00614.92
7.2.230.0040.01115.23
7.2.220.0060.00915.27
7.2.210.0070.01114.98
7.2.200.0090.00615.16
7.2.190.0040.00815.04
7.2.180.0040.00815.18
7.2.170.0060.01415.21
7.2.160.0120.00615.20
7.2.150.0100.00317.11
7.2.140.0030.01016.91
7.2.130.0110.00116.90
7.2.120.0060.00816.99
7.2.110.0080.00416.64
7.2.100.0050.00917.03
7.2.90.0020.01216.91
7.2.80.0070.01016.97
7.2.70.0080.00417.04
7.2.60.0050.00816.89
7.2.50.0080.00616.82
7.2.40.0070.00716.91
7.2.30.0100.00517.01
7.2.20.0060.00616.88
7.2.10.0100.00616.94
7.2.00.0020.01017.10
7.1.330.0120.00615.82
7.1.320.0090.00915.86
7.1.310.0030.01315.88
7.1.300.0070.00715.94
7.1.290.0070.00716.03
7.1.280.0070.00315.98
7.1.270.0090.00615.88
7.1.260.0080.00515.98
7.1.250.0100.00315.73
7.1.240.0070.00715.89
7.1.230.0000.01315.89
7.1.220.0100.00315.76
7.1.210.0040.00815.87
7.1.200.0040.00615.66
7.1.190.0100.00715.77
7.1.180.0000.01215.79
7.1.170.0120.00315.86
7.1.160.0060.00915.79
7.1.150.0080.00415.89
7.1.140.0030.01315.68
7.1.130.0080.00615.94
7.1.120.0040.00415.74
7.1.110.0100.00315.69
7.1.100.0070.00715.82
7.1.90.0070.01015.89
7.1.80.0050.00515.82
7.1.70.0090.00816.50
7.1.60.0100.01017.77
7.1.50.0060.00516.38
7.1.40.0000.00815.46
7.1.30.0060.01216.02
7.1.20.0070.01015.60
7.1.10.0040.00815.55
7.1.00.0040.04319.10
7.0.330.0110.00315.60
7.0.320.0070.00715.39
7.0.310.0030.00715.52
7.0.300.0000.01215.48
7.0.290.0000.01315.52
7.0.280.0060.00615.41
7.0.270.0060.00915.54
7.0.260.0000.01315.36
7.0.250.0060.00615.33
7.0.240.0080.00015.19
7.0.230.0060.00615.44
7.0.220.0080.00415.38
7.0.210.0070.00415.52
7.0.200.0110.00316.18
7.0.190.0080.00415.28
7.0.180.0000.01015.57
7.0.170.0030.01315.57
7.0.160.0060.00715.43
7.0.150.0070.00415.43
7.0.140.0070.03918.80
7.0.130.0040.01115.45
7.0.120.0040.01115.52
7.0.110.0040.00415.35
7.0.100.0090.00615.13
7.0.90.0040.01115.44
7.0.80.0070.00315.54
7.0.70.0060.00615.52
7.0.60.0100.04117.64
7.0.50.0020.02716.64
7.0.40.0130.04016.95
7.0.30.0180.04016.84
7.0.20.0150.04616.74
7.0.10.0130.02516.75
7.0.00.0030.02716.83
5.6.400.0060.00614.47
5.6.390.0150.00014.72
5.6.380.0080.00614.29
5.6.370.0110.00414.36
5.6.360.0000.01014.60
5.6.350.0000.01614.66
5.6.340.0030.00614.45
5.6.330.0070.00714.55
5.6.320.0060.00614.49
5.6.310.0030.00914.34
5.6.300.0070.00714.41
5.6.290.0110.00414.57
5.6.280.0050.03817.82
5.6.270.0000.01014.30
5.6.260.0040.00814.48
5.6.250.0080.00014.77
5.6.240.0030.00914.62
5.6.230.0060.00314.54
5.6.220.0040.00414.21
5.6.210.0050.04317.64
5.6.200.0060.03116.46
5.6.190.0100.04217.53
5.6.180.1830.02617.54
5.6.170.0230.03517.45
5.6.160.0090.04317.35
5.6.150.0080.04116.29
5.6.140.0050.04716.41
5.6.130.0080.03316.18
5.6.120.0050.03117.68
5.6.110.0030.03017.68
5.6.100.0060.04017.74
5.6.90.0070.03617.65
5.6.80.0060.04517.24
5.6.70.1620.02017.32
5.6.60.0030.01014.13
5.6.50.0040.01514.05
5.6.40.0030.00714.37
5.6.30.0000.01314.10
5.6.20.0070.00314.19
5.6.10.0000.01414.46
5.6.00.0030.00614.60
5.5.380.0120.00314.52
5.5.370.0080.00414.63
5.5.360.0070.00714.54
5.5.350.0020.04017.36
5.5.340.0080.03416.11
5.5.330.0050.02917.26
5.5.320.0150.03017.29
5.5.310.0180.03817.47
5.5.300.0070.02216.23
5.5.290.0080.03516.24
5.5.280.0080.02317.58
5.5.270.0090.04317.50
5.5.260.0110.01817.61
5.5.250.0110.03017.54
5.5.240.0050.04417.19
5.5.230.0070.00414.53
5.5.220.0080.00414.30
5.5.210.0110.00714.25
5.5.200.0070.00414.48
5.5.190.0060.00614.16
5.5.180.0040.00814.14
5.5.170.0060.00914.23
5.5.160.0030.00614.41
5.5.150.0040.01114.53
5.5.140.0000.01214.18
5.5.130.0000.01414.39
5.5.120.0040.00714.32
5.5.110.0130.00014.13
5.5.100.0030.01014.21
5.5.90.0040.00414.35
5.5.80.0030.00614.48
5.5.70.0030.01014.13
5.5.60.0000.00814.31
5.5.50.0060.00914.38
5.5.40.0030.01314.14
5.5.30.0100.00014.35
5.5.20.0060.00614.27
5.5.10.0000.01114.29
5.5.00.0000.01213.93
5.4.450.0110.02515.76
5.4.440.0350.02815.75
5.4.430.0050.03115.73
5.4.420.0110.02815.73
5.4.410.0100.02715.67
5.4.400.0400.00415.42
5.4.390.0420.00315.33
5.4.380.0160.02915.27
5.4.370.0150.03415.29
5.4.360.0150.03215.38
5.4.350.0170.02715.34
5.4.340.0130.02815.21
5.4.330.0000.00911.94
5.4.320.0040.02212.22
5.4.310.0050.03112.22
5.4.300.0040.02312.22
5.4.290.0040.02412.22
5.4.280.0040.02212.17
5.4.270.0070.02815.30
5.4.260.0100.02815.35
5.4.250.0050.02815.42
5.4.240.0050.03215.43
5.4.230.0110.03915.34
5.4.220.0080.02915.29
5.4.210.0050.02815.40
5.4.200.0060.03415.47
5.4.190.0050.02815.44
5.4.180.0050.03115.42
5.4.170.0080.02615.46
5.4.160.0030.03215.39
5.4.150.0100.03015.28
5.4.140.0050.03214.17
5.4.130.0050.02614.18
5.4.120.0050.03414.23
5.4.110.0050.03114.18
5.4.100.0080.02514.13
5.4.90.0100.03214.19
5.4.80.0100.03514.20
5.4.70.0070.03714.12
5.4.60.0050.02914.13
5.4.50.0080.03314.09
5.4.40.0030.02814.22
5.4.30.0100.02714.14
5.4.20.0100.02314.21
5.4.10.0100.02914.12
5.4.00.0050.02713.92
5.3.290.0080.02212.37
5.3.280.0030.03013.25
5.3.270.0050.03413.28
5.3.260.0080.02813.36
5.3.250.0090.03213.31
5.3.240.0070.02613.23
5.3.230.0090.02913.26
5.3.220.0070.03913.18
5.3.210.0050.03113.34
5.3.200.0080.03113.30
5.3.190.0060.02613.26
5.3.180.0070.02913.28
5.3.170.0080.03713.17
5.3.160.0120.02713.36
5.3.150.0050.02713.24
5.3.140.0100.03713.34
5.3.130.0100.03213.36
5.3.120.0110.02313.23
5.3.110.0060.02613.20
5.3.100.0040.03513.03
5.3.90.0080.02513.03
5.3.80.0070.02313.01
5.3.70.0050.03712.99
5.3.60.0120.03013.01
5.3.50.0080.02412.98
5.3.40.0030.03813.05
5.3.30.0020.03712.96
5.3.20.0070.03512.83
5.3.10.0070.02512.78
5.3.00.0090.02412.87
5.2.170.0030.04311.21
5.2.160.0100.03311.05
5.2.150.0100.04711.37
5.2.140.0070.05711.23
5.2.130.0100.03311.10
5.2.120.0070.03311.08
5.2.110.0070.05011.29
5.2.100.0100.03711.08
5.2.90.0100.05011.09
5.2.80.0070.04711.09
5.2.70.0100.03711.17
5.2.60.0130.05011.15
5.2.50.0170.04311.21
5.2.40.0000.04710.92
5.2.30.0130.05311.04
5.2.20.0000.04311.14
5.2.10.0000.04310.87
5.2.00.0030.05010.89
5.1.60.0100.03010.25
5.1.50.0070.04310.25
5.1.40.0130.04010.08
5.1.30.0100.04710.41
5.1.20.0030.04310.34
5.1.10.0130.04010.12
5.1.00.0000.03710.03
5.0.50.0000.0438.66
5.0.40.0070.0338.41
5.0.30.0070.0478.21
5.0.20.0030.0308.18
5.0.10.0000.0308.29
5.0.00.0030.0438.19
4.4.90.0070.0175.88
4.4.80.0030.0205.94
4.4.70.0000.0235.87
4.4.60.0000.0235.91
4.4.50.0000.0305.88
4.4.40.0030.0335.85
4.4.30.0000.0235.85
4.4.20.0030.0205.93
4.4.10.0000.0235.95
4.4.00.0030.0335.96
4.3.110.0000.0235.79
4.3.100.0100.0275.76
4.3.90.0030.0205.73
4.3.80.0030.0305.79
4.3.70.0000.0205.73
4.3.60.0000.0235.76
4.3.50.0000.0275.69
4.3.40.0070.0275.71
4.3.30.0070.0205.57
4.3.20.0030.0205.57
4.3.10.0000.0235.57
4.3.00.0030.0207.09

preferences:
45.45 ms | 400 KiB | 5 Q