Created
March 15, 2018 10:40
-
-
Save jaredchu/e5274bc6f16b014aac79963458b6ad37 to your computer and use it in GitHub Desktop.
This file contains 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 | |
$handle = fopen ("php://stdin","r"); | |
fscanf($handle,"%d %d",$n,$k); | |
$a_temp = fgets($handle); | |
$a = explode(" ",$a_temp); | |
array_walk($a,'intval'); | |
function rotate_left($arr, $k){ | |
$left = array_reverse(array_slice($arr,0,$k)); | |
$right = array_reverse(array_slice($arr,$k,count($arr))); | |
return array_reverse(array_merge($left,$right)); | |
} | |
echo(implode( ' ',rotate_left($a,$k))); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment