Skip to content

Instantly share code, notes, and snippets.

@rafaelbernard
Last active January 17, 2016 02:33
Show Gist options
  • Save rafaelbernard/a7ce7de683c9514dcc41 to your computer and use it in GitHub Desktop.
Save rafaelbernard/a7ce7de683c9514dcc41 to your computer and use it in GitHub Desktop.
<?php
// you can write to stdout for debugging purposes, e.g.
// print "this is a debug message\n";
function solution($A, $K) {
// write your code in PHP5.5
$count = count($A);
$length_offset = $count - $K;
if ($length_offset < 0) {
$quo = intval($K / $count);
$over = $quo * $count;
$length_offset = $count - ($K - $over);
}
$sufix = array_slice($A, 0, $length_offset);
$prefix = array_slice($A, $length_offset);
return array_merge($prefix, $sufix);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment