/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
class Solution {
public ListNode middleNode(ListNode head) {
ListNode p,q;
p=q=head;
while(q!=null&&q.next!=null){
q=q.next.next;
p=p.next;
}
return p;
}
}