Created
February 20, 2021 18:49
-
-
Save richard457/613cba56427394c8740a66f4dd85f516 to your computer and use it in GitHub Desktop.
Rotate Array given K step.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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