Code does not seem to be passing but I can't seem to spot my error, Can anyone help me out on where I am going wrong?
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));
ArrayList<String> list = new ArrayList<>();
//Declare N and M
int N = Integer.parseInt(reader.readLine());
int M = Integer.parseInt(reader.readLine());
//Add N to list
for (int i = 0; i < N ; i++) {
list.add(reader.readLine());
}
//Add M to list
for (int i = 0; i < M; i++) {
list.add(list.get(i));
}
//Remove 0 to M in List
for (int i = M; i >-1 ; i--) {
list.remove(i);
}
//Print list
for (String l : list){
System.out.println(l);
}
}
}