:type head: ListNode :type n: int :rtype: ListNode
(self, head, n)
| 62 | |
| 63 | class Solution(object): |
| 64 | def removeNthFromEnd(self, head, n): |
| 65 | """ |
| 66 | :type head: ListNode |
| 67 | :type n: int |
| 68 | :rtype: ListNode |
| 69 | """ |
| 70 | my_head = my_trail = head |
| 71 | for i in range(n): |
| 72 | my_head = my_head.next |
| 73 | |
| 74 | if not my_head: |
| 75 | return head.next |
| 76 | |
| 77 | while my_head.next: |
| 78 | my_head = my_head.next |
| 79 | my_trail = my_trail.next |
| 80 | |
| 81 | my_trail.next = my_trail.next.next |
| 82 | |
| 83 | return head |
| 84 | # list_node = [] |
| 85 | # my_head = head |
| 86 | # while my_head: |
nothing calls this directly
no outgoing calls
no test coverage detected