标签:code linked play spl type tno splay style else
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def removeNthFromEnd(self, head,n): """ :type head: ListNode :type n: int :rtype: ListNode """ def remove(h,n): if h.next: c = remove(h.next,n) else: return 1 if c == n: h.next = h.next.next return c + 1 result = ListNode(0) result.next = head remove(result,n) return result.next
leetcode 19-> Remove Nth Node From End of List
标签:code linked play spl type tno splay style else
原文地址:https://www.cnblogs.com/sea-stream/p/10525080.html