Answers for "remove loop in linked list"

1

remove arraylist index in for loop

for (int i = data.size()-1; i >= 0; i--){
    if (data.get(i).contains(element)){
            data.remove(i);
    }
 }
Posted by: Guest on May-19-2020
2

how to add a list in a list java

List<SomePojo> list = new ArrayList<SomePojo>();

List<SomePojo> anotherList = new ArrayList<SomePojo>();
anotherList.add(list);
Posted by: Guest on February-15-2020
0

remove loop from linked list

//java 

Node remove(Node head){
//detect the loop
Node slow=head;
Node fast=head;
while(slow!=null&&fast!=null&&fast.next!=null){
slow=slow.next;
fast=fast.next.next;
if(slow==fast){
if(slow==head){
while(slow.next!=head){
slow=slow.next;
}
slow.next=null;
}
if(slow==fast){
slow=head;
while(slow.next!=fast.next){
if(slow==fast.next){
fast.next=null;
}
slow=slow.next;
fast=fast.next;
}
fast.next=null;
}
}
}
Posted by: Guest on September-29-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language