1、题目描述
2、问题分析
直接计算,操作。
3、代码
ListNode* removeNthFromEnd(ListNode* head, int n) {
if (head == NULL)
return head;
int len = ;
ListNode *p = head;
while (p != NULL) {
len++;
p = p->next;
} int step = len - n;
if (step == )
return head->next;
p = head;
while (--step) {
p = p->next;
} ListNode *tmp = p->next->next;
p->next = tmp; return head; }