2020-05-30 04:23:24 +08:00
|
|
|
void rotate(int *nums, int numsSize, int k)
|
|
|
|
{
|
|
|
|
for (int i = 1; i <= k; i++)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
int lastElement;
|
|
|
|
lastElement = nums[numsSize - 1];
|
|
|
|
for (j = numsSize - 1; j > 0; j--)
|
|
|
|
{
|
|
|
|
nums[j] = nums[j - 1];
|
|
|
|
}
|
|
|
|
nums[0] = lastElement;
|
2019-10-26 22:02:44 +08:00
|
|
|
}
|
|
|
|
}
|