My issue
How can I do this in PHP?
My code
<?php
$t = readline();
for($i = 0; $i < $t; $i++) {
$n = readline();
$speed = explode(' ', readline());
$j = 1;
$total = 1; // Because the first car is always moving that the maximum speed.
while($j < $n) {
if($speed[$j] < $speed[$j - 1])
$total++;
$j++;
}
print($total . PHP_EOL);
}
Learning course: Level up from 1* to 2*
Problem Link: CodeChef: Practical coding for everyone