Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Complete the rotLeft function below.
- static int[] rotLeft(int[] a, int d) {
- for(int i = 0; i < d; i++){
- int lastIndex = a.length - 1;
- //Hold first element
- int temp = a[0];
- for(int index = 0; index < lastIndex; index++){
- a[index] = a[index + 1];
- }
- //Set last element to the prev first
- a[lastIndex] = temp;
- }
- return a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement