Skip to content

Commit 442f233

Browse files
authored
Merge pull request AlgoMaster-io#9 from eliphosif/patch-1
docs: correct inline conditional syntax
2 parents baebd18 + c3aa567 commit 442f233

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

go/intersection-of-two-linked-lists.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,17 @@ func getIntersectionNode(headA, headB *ListNode) *ListNode {
9292
// Both pointers move through both lists
9393
for a != b {
9494
// When reaching the end of a list, switch to the head of the other list
95-
a = if a == nil { headB } else { a.Next }
96-
b = if b == nil { headA } else { b.Next }
95+
if a == nil {
96+
a = headB
97+
} else {
98+
a = a.Next
99+
}
100+
101+
if b == nil {
102+
b = headA
103+
} else {
104+
b = b.Next
105+
}
97106
}
98107

99108
return a // or b, both are the intersection node or nil if no intersection

0 commit comments

Comments
 (0)