The code seems correct but tasks failing
package com.codegym.task.task07.task0720;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
/*
Shuffled just in time
Use the keyboard to enter 2 numbers N and M.
Enter N strings and put them in a list.
Move the first M strings to the end of the list.
Display the list, each value on a new line.
Note:
you must not create more than one list.
Requirements:
1. Declare a string list variable and immediately initialize it.
2. Read numbers N and M from the keyboard. Read N strings and add them to the list.
3. Move the first M strings to the end of the list.
4. Display the list, each value on a new line.
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
ArrayList<String> list = new ArrayList<String>();
for (int i=0; i<N; i++) {
String readStr = sc.nextLine();
list.add(readStr);
// list[i] = readInt;
}
for (int i=0; i<M; i++) {
String str = list.get(0);
list.remove(0);
list.add(str);
}
// System.out.println(list.size());
for (int i=0; i<list.size(); i++) {
System.out.println(list.get(i));
}
//write your code here
}
}