Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Last active November 7, 2020 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbvf50mobile/37878902ea6a1da25383a9ec8a9ce3ba to your computer and use it in GitHub Desktop.
Save lbvf50mobile/37878902ea6a1da25383a9ec8a9ce3ba to your computer and use it in GitHub Desktop.
Just PHP FUN 146.
<?php
# https://www.codewars.com/kata/544975fc18f47481ba00107b Circularly Sorted Array.
function isCircleSorted($arr) {
$min = min($arr);
$start = array_search($min,$arr);
$prev = $min; $n = count($arr);
for($i = 0, $j = ($start+1)%$n; $i < ($n-1); $i += 1, $j = ($j+1)%$n){
$x = $arr[$j];
if($x < $prev) return false;
$prev = $x;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment