Generation

generate functionTue, 24 Jan 2023

how to shift an array to the right

void rotate(int nums[], int n, int k) { int temp; while(k--){ temp = nums[n-1]; for(int i = n-1; i > 0; i--){ nums[i] = nums[i-1]; } nums[0] = temp; } }

Questions about programming?Chat with your personal AI assistant