php array rotation
P粉043295337
2023-09-03 14:08:19
<p>Of these two integer arrays, how do I determine if the second array is a rotated version of the first array and which php function is required? </p>
<p>Example:
Original array A=[1,2,3,4,5,6,7,8]
Rotate array B=[6,7,8,1,2,3,4,5]</p>
<p>In this example, all numbers in array A are rotated 5 positions to the right. </p>
There is no built-in function, but you can rotate each position and compare whether it is correct.
Output