its showing output [ c, d, e, a, c] for
5
2
a
b
c
d
e
package com.codegym.task.task07.task0720;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Shuffled just in time
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(reader.readLine());
int M = Integer.parseInt(reader.readLine());
ArrayList<String> list = new ArrayList<String>();
for(int i=0; i<N; i++){
String s = reader.readLine();
list.add(s);
}
String[] array = new String[M];
for(int i=0; i<M; i++){
array[i]=list.get(i);
list.remove(0);
}
for(int i=0;i<array.length;i++){
list.add(array[i]);
}
System.out.println(list);
}
}