Java Solution In One Pass


#1

public class Solution {
public int solve(ListNode A) {
if(A.next==null ) return A.val;
ListNode fast=A;
ListNode slow=A;
while(fast!=null && fast.next!=null) {
fast=fast.next.next;
slow=slow.next;
}
return slow.val;
}
}