Created
April 15, 2020 17:27
-
-
Save MagedAhmad/d19d47f61153cb19fab01fd6fdceb108 to your computer and use it in GitHub Desktop.
Hackerrank Arrays left rotation
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 | |
| function rotLeft($a, $d) { | |
| $temp = []; | |
| for($i = 0; $i < $d; $i++) { | |
| $temp[$i] = $a[$i]; | |
| } | |
| $a = array_slice($a, $d); | |
| $result = array_merge($a, $temp); | |
| return $result; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment