CodePudding user response:
Public ListNode middleNode (ListNode head) {ListNode fast=head;
ListNode missile=head;
While (fast!=null & amp; & Fast. Next!=null) {
Fast=fast. Next. Next;
Missile=missile. The next;
}
Return the missile;
}
CodePudding user response:
Public ListNode middleNode (ListNode head) {
ListNode fast=head;
ListNode missile=head;
While (fast!=null & amp; & Fast. Next!=null) {
If (fast. Next. Next!=null) {
Fast=fast. Next. Next;
Missile=missile. The next;
} else {
Fast=fast. Next;
//missile=missile. The next//node is even, the intermediate nodes can be moved to the position on the
}
}
Return the missile;
}