添加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

@@ -163,3 +163,23 @@ class Solution {
}
}
```
Go Code:
```go
func getKthFromEnd(head *ListNode, k int) *ListNode {
if head == nil { return head }
pro, after := head, head
//先移动绿指针到指定位置
for i := 0; i < k - 1; i++ {
pro = pro.Next
}
for pro.Next != nil {
pro = pro.Next
after = after.Next
}
return after
}
```