添加Go语言题解

This commit is contained in:
zouxinyao
2021-07-28 02:26:32 +08:00
parent 7eb8b4a9fd
commit 575b7612f0
52 changed files with 1679 additions and 104 deletions

View File

@@ -265,6 +265,28 @@ class Solution {
}
```
Go Code:
```go
func getIntersectionNode(headA, headB *ListNode) *ListNode {
tempA, tempB := headA, headB
for tempA != tempB {
// 如果不为空就指针下移,为空就跳到另一链表的头部
if tempA == nil {
tempA = headB
} else {
tempA = tempA.Next
}
if tempB == nil {
tempB = headA
} else {
tempB = tempB.Next
}
}
return tempA
}
```
好啦链表的题目就结束啦希望大家能有所收获下周就要更新新的题型啦继续坚持肯定会有收获的
<br/>