Skip to content

Commit c81513f

Browse files
authored
Update Remove Nth Node from End of List - Leetcode 19.py
1 parent a686182 commit c81513f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Remove Nth Node from End of List - Leetcode 19.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ def removeNthFromEnd(self, head: Optional[ListNode], n: int) -> Optional[ListNod
66

77
for _ in range(n + 1):
88
ahead = ahead.next
9+
910
while ahead:
1011
behind = behind.next
1112
ahead = ahead.next
1213

1314
behind.next = behind.next.next
1415

1516
return dummy.next
17+
18+
# Time Complexity: O(n)
19+
# Space Complexity: O(1)

0 commit comments

Comments
 (0)