MCPcopy Create free account
hub / github.com/EndlessCheng/codeforces-go / getIntersectionNode

Function getIntersectionNode

leetcode/main.go:885–903  ·  view source on GitHub ↗

LC 160

(headA, headB *ListNode)

Source from the content-addressed store, hash-verified

883
884// LC 160
885func getIntersectionNode(headA, headB *ListNode) *ListNode {
886 if headA == nil || headB == nil {
887 return nil
888 }
889 pa, pb := headA, headB
890 for pa != pb {
891 if pa == nil {
892 pa = headB
893 } else {
894 pa = pa.Next
895 }
896 if pb == nil {
897 pb = headA
898 } else {
899 pb = pb.Next
900 }
901 }
902 return pa
903}
904
905// LC 162
906func findPeakElement(a []int) int {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected