Created
April 15, 2020 14:40
-
-
Save MagedAhmad/bb339e2c85dd69470ea72c49e45b3288 to your computer and use it in GitHub Desktop.
Hackerrank Jumping on the Clouds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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