/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/funcremoveNthFromEnd(head*ListNode,nint)*ListNode{dummyNode:=&ListNode{Next:head}slow,fast:=head,headforn>0&&fast!=nil{fast=fast.Nextn--}prev:=dummyNodeforfast!=nil{prev=slowslow=slow.Nextfast=fast.Next}prev.Next=slow.NextreturndummyNode.Next}