Skip to content

Instantly share code, notes, and snippets.

@MagedAhmad
Created April 15, 2020 14:40
Show Gist options
  • Select an option

  • Save MagedAhmad/bb339e2c85dd69470ea72c49e45b3288 to your computer and use it in GitHub Desktop.

Select an option

Save MagedAhmad/bb339e2c85dd69470ea72c49e45b3288 to your computer and use it in GitHub Desktop.
Hackerrank Jumping on the Clouds
<?php
// 0 0 0 0 1 0
function jumpingOnClouds($c) {
$start = 0;
$counts = 0;
while($start < count($c) - 1) {
if( ($start + 2) < count($c) && $c[$start + 2] != 1) {
$counts++;
$start = $start + 2;
}else {
$counts++;
$start++;
}
}
return $counts;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment