Coding Bat – rotateLeft3

This exercise requires that the program look at an array with 3 integers and shift their positions one index to the left (down) and place first integer (index 0) at the end.

Here is the code that you start with:

public int[] rotateLeft3(int[] nums) {


As you can see, we start with an empty integer array named “nums”.

public int[] rotateLeft3(int[] nums) {
  int[] rotatedArray = new int[]{nums[1],nums[2],nums[0]};
  return rotatedArray;


This solution creates a new integer array named “rotatedArray” and assigns it the values of each index from the original array. (Line 2)

We return the new array on line 3 to solve the problem.

Leave a Reply

Your email address will not be published. Required fields are marked *