19. Remove Nth Node From End of List——linklist

class Solution(object):
    def repeatedNTimes(self, head, n):
        left = right = head
        for i in range(n):
            right = right.next
        if right is None:
            return head.next  # special
        while right.next is not None:
            right = right.next
            left = left.next

        left.next = left.next.next
        return head

相关文章: