ListNode findMeetingPoint(ListNode head) {
ListNode slow = head;
ListNode fast = head;
while (fast != null && fast.next != null) {
slow = slow.next;
fast = fast.next.next;
if (slow == fast) return slow;
}
return null;
}
def find_meeting_point(head):
slow = fast = head
while fast and fast.next:
slow = slow.next
fast = fast.next.next
if slow is fast:
return slow
return None
def findMeetingPoint(head: ListNode): ListNode =
var slow = head
var fast = head
while fast != null && fast.next != null do
slow = slow.next
fast = fast.next.next
if slow == fast then return slow
null
ListNode* findMeetingPoint(ListNode* head) {
ListNode* slow = head;
ListNode* fast = head;
while (fast != nullptr && fast->next != nullptr) {
slow = slow->next;
fast = fast->next->next;
if (slow == fast) return slow;
}
return nullptr;
}