In this video we will learn how to split circular linked list.
Node slowP=list.head;
Node fastP=list.head;
if(list.head == null){
return;
}
while(fastP.next != list.head && fastP.next.next !=list.head){
fastP=fastP.next.next;
slowP=slowP.next;
}
if(fastP.next.next == list.head){
fastP=fastP.next;
}
list.head1=list.head;
if(list.head.next != list.head){
list.head2=slowP.next;
}
fastP.next=slowP.next;
slowP.next=list.head;
Ещё видео!