Hello! I tried the code with several different M and N values and although I am getting the correct output for each my program is not verifying. Any help would be appreciated, thanks!
package com.codegym.task.task07.task0720;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
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<String>();
int N = Integer.parseInt(reader.readLine());
int M = Integer.parseInt(reader.readLine());
for(int i = 0; i <= N;i++){
list.add(i, reader.readLine());
}
String mString = list.get(M);
for( int i = 0; i<= list.size();){
if(list.get(i).equals(mString)){
break;
}
else{
list.add(list.size() - 1, list.get(i));
list.remove(i);
}
}
for(int i = 0; i < list.size();i++){
System.out.println(list.get(i));
}
}
}