求中间结点
This commit is contained in:
parent
31b0908077
commit
e1347e4bf1
@ -301,6 +301,7 @@ public class SinglyLinkedList {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[]args){
|
||||
|
||||
SinglyLinkedList link = new SinglyLinkedList();
|
||||
|
@ -144,7 +144,7 @@ public class LinkedListAlgo {
|
||||
Node fast = list;
|
||||
Node slow = list;
|
||||
|
||||
while (fast.next != null && fast.next.next != null) {
|
||||
while (fast != null && fast.next != null) {
|
||||
fast = fast.next.next;
|
||||
slow = slow.next;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user