Java 8 Approach


#1

public class Solution {
public ArrayList rotateArray(ArrayList A, int requiredShifts) {
int[] arrayA = A.stream().mapToInt(i->i).toArray();
int noOfShifts = 0;

    while(noOfShifts < requiredShifts){
        int temp = arrayA[0];
        for(int iteration=0; iteration< arrayA.length -1; iteration++){
            arrayA[iteration] = arrayA[iteration+1];
            arrayA[iteration+1] = temp;
        }
        noOfShifts++;
    }
    ArrayList<Integer> shuffledList = new ArrayList<>();
    Arrays.stream(arrayA).forEach(element -> shuffledList.add(element));
    return shuffledList;
}

}