class Solution:
def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode:
dummy = ListNode(0, head)
first = head
second = dummy
for i in range(n):
first = first.next
while first:
first = first.next
second = second.next
second.next = second.next.next
return dummy.next
?
class Solution:
def removeNthFromEnd(self,head:ListNode,n:int)->ListNode:
dummy = ListNode(0,head)
first =head
second =dummy
for i in range(n):
first = first.next
while first:
first =first.next
second = second.next
second.next =second.next.next
return dummy.next
class Solution:
def removeNthFromEnd(self,head:ListNode,n:int)-> ListNode:
dummy = ListNode(0,head)
first =head
second = dummy
for i in range(n):
first = first.next
while first:
first = first.next
second = second.next
second.next = second.next.next
return dummy.next
?
class Solution:
def removeNthFromEnd(self,head:ListNode,n:int) -> ListNode:
dummy = ListNode(0,head)
first = head
second = dummy
for i in range(n):
first =first.next
while first:
first = first.next
second = second.next
second.next = second.next.next
return dummy.next
|