19. Remove Nth Node From End of List
2016-08-17 00:27
246 查看
class Solution { public: ListNode* removeNthFromEnd(ListNode* head, int n) { ListNode* Head=new ListNode(-1); Head->next=head; ListNode* pre=Head,*cur=Head; int len=0; while(cur&&len<=n) { len++; cur=cur->next; } while(cur) { cur=cur->next; pre=pre->next; } pre->next=pre->next->next; head=Head->next; delete Head; return head; } };
相关文章推荐
- LeetCode-19:Remove Nth Node From End of List
- leetcode 19 Remove Nth Node From End of List
- LeetCode 19. Remove Nth Node From End of List
- LeetCode 19. Remove Nth Node From End of List(删除链表)
- LeetCode 19. Remove Nth Node From End of List
- 【C++】【LeetCode】19. Remove Nth Node From End of List
- LeetCode-19 Remove Nth Node From End of List(移除尾部第N个节点)
- LeetCode (19)Remove Nth Node From End of List
- LeetCodet题解--19. Remove Nth Node From End of List(删除链表的倒数第n个元素)
- Leetcode_19:Remove Nth Node From End of List
- 19. Remove Nth Node From End of List
- LeetCode 19. Remove Nth Node From End of List
- 19. Remove Nth Node From End of List题解
- 19 Remove Nth Node From End of List
- [LeetCode]19. Remove Nth Node From End of List
- LeetCode之19---Remove Nth Node From End of List
- 【Leetcode】19. Remove Nth Node From End of List
- [LeetCode] 19. Remove Nth Node From End of List 删除链表的倒数第N个节点 @python
- 19. Remove Nth Node From End of List
- 菜鸟刷leetcode 19. Remove Nth Node From End of List