Skip to content

Instantly share code, notes, and snippets.

@richard457
Created February 20, 2021 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richard457/613cba56427394c8740a66f4dd85f516 to your computer and use it in GitHub Desktop.
Save richard457/613cba56427394c8740a66f4dd85f516 to your computer and use it in GitHub Desktop.
Rotate Array given K step.
public static void rotate(int [] arr, int k){
int j =0;
while(k>0){
int temp = arr[arr.lenght -1]
for(j=arr.lenght -1; j>0; j--){
arr[j] = arr[j-1]
}
arr[j] = temp;
k--;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment