Skip to content

Commit e09f23a

Browse files
committed
1752
1 parent 447a02d commit e09f23a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
class Solution
3+
{
4+
/**
5+
* @param Integer[] $nums
6+
* @return Boolean
7+
*/
8+
public function check($nums)
9+
{
10+
11+
$count = count($nums);
12+
$countBreaks = 0;
13+
14+
for ($i = 0; $i < $count; $i++) {
15+
if ($nums[$i] > $nums[($i + 1) % $count]) { // Circular check
16+
$countBreaks++;
17+
}
18+
}
19+
20+
return $countBreaks <= 1;
21+
}
22+
}
23+
24+
$solution = new Solution();
25+
26+
$nums = [1, 2, 3, 4, 5, 6];
27+
28+
echo $solution->check($nums); // Output: true

0 commit comments

Comments
 (0)