1 Star 0 Fork 0

catyMap/AlgorithmNote

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
removeNthFromEnd.go 511 Bytes
Copy Edit Raw Blame History
catyMap authored 2021-03-30 22:11 +08:00 . 未归类算法题目提交
package main
import "fmt"
type ListNode struct {
Val int
Next *ListNode
}
func main() {
node := &ListNode{1,nil}
fmt.Println(removeNthFromEnd(node,1))
}
func removeNthFromEnd(head *ListNode , n int) *ListNode {
var curr int = 0
var Recurse func(head *ListNode , n int) *ListNode
Recurse = func(head *ListNode, n int) *ListNode {
if head == nil {
return nil
}
head.Next = Recurse(head.Next , n)
curr ++
if curr == n {
return head.Next
}
return head
}
return Recurse(head , n)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/dogemap/algorithm-note.git
git@gitee.com:dogemap/algorithm-note.git
dogemap
algorithm-note
AlgorithmNote
dc486f96f6c1

Search