link list in java of length,n.a number,m is given and the program needs to on the mth node remove the node and continue doing so until the last node remains.
import java.util.LinkedList;
public class Question4817 {
public static LinkedList list = new LinkedList();
public static void inputData(){
& list.add("Fisrt");
& list.add("1");
& list.add("Second");
& list.add("3");
& list.add("Four");
}
public static void removeData(){
& while(!list.isEmpty()){
& System.out.println(list.peek() + " removing");
& list.poll();
&
& }
}
public static void main(String[] args) {
& // TODO Auto-generated method stub
&
& inputData();
& removeData();
& System.out.println("Done!");
}
}