You should definitely familiarize with the 'modulus' operator %
– calculating the 'un-rotated' (original) position of the item to find is waaay faster than performing a hundred thousand rotations (k is up to \10ドル^5\$) of one hundred thousand-item array (n up to \10ドル^5\$).
It is even faster than a single rotation.
But that is for StackOverflow rather than CodeReview...
CiaPan
- 1.9k
- 1
- 12
- 17
default