import java.util.ArrayList;
import java.util.List;

public class HackerRankLeftRotations {

    public static int[] methodToImplement2(int[] a, int d) {
        List<Integer> arr = new ArrayList<>();
        for(int i:a) {
            arr.add(i);
        }
        System.out.println("as a list: " + arr);

        List<Integer> newList = new ArrayList<>();
        for(int i=0;i<d;i++) {
            int first = arr.get(i);
            newList = arr.subList(i+1,arr.size());
            newList.add(first);
            System.out.println("With first last " + newList);
        }

        return newList.stream().mapToInt(i->i).toArray();
    }

    public static void main (String[] args) {

        int[] a = {1,2,3,4,5};
        int d = 4;
        methodToImplement2(a, d);
    }
}
