classSolution { public: voidrotate(vector<int>& nums, int k){ int count = 0; int start = 0; int pre = nums[0]; int index = start; while(count < nums.size()) { count += 1; int nextIndex = (index + k) % nums.size(); int temp = nums[nextIndex]; nums[nextIndex] = pre; pre = temp; index = nextIndex; if (index == start) {start += 1; index += 1; pre = nums[index];} cout << index << endl; } } };