LeetCode-Remove Nth Node From End of List
来源:互联网 发布:淘宝网店铺怎么装修 编辑:程序博客网 时间:2024/06/06 03:51
ListNode *removeNthFromEnd(ListNode *head, int n){ if(head==NULL || (head->next==NULL && n==1)) return NULL; ListNode *pNode = head; int length=0; while(pNode!=NULL) { ++length; pNode=pNode->next; } if(n>length) return head; if(n==length && head->next!=NULL) return head->next; int rest=length-n-1; pNode=head; while(rest-- && pNode!=NULL) { pNode=pNode->next; } if(n==1) pNode->next=NULL; else pNode->next=pNode->next->next; return head;}
0 0
- LeetCode[Linked List]: Remove Nth Node From End of List
- 19. Remove Nth Node From End of List leetcode list
- [Leetcode]LeetCode 19:Remove Nth Node From End of List
- LeetCode: Remove Nth Node From End of List
- LeetCode: Remove Nth Node From End of List
- [Leetcode] Remove Nth Node From End of List
- LeetCode: Remove Nth Node From End of List
- leetcode 40: Remove Nth Node From End of List
- [LeetCode] Remove Nth Node From End of List
- Leetcode 19 Remove Nth Node From End of List
- [Leetcode] Remove Nth Node From End of List
- [LeetCode]Remove Nth Node From End of List
- LeetCode-Remove Nth Node From End of List
- [LeetCode] Remove Nth Node From End of List
- LeetCode 19: Remove Nth Node From End of List
- LeetCode - Remove Nth Node From End of List
- LeetCode | Remove Nth Node From End of List
- leetcode之Remove Nth Node From End of List
- C#中的值类型与引用类型
- iOS更换皮肤的思路与代码实现
- 黑马程序员—OC—类方法 && self
- 基于直方图均衡化的水下激光图像处理(MATLAB仿真)
- ZOJ1710
- LeetCode-Remove Nth Node From End of List
- 国企,私企与外企利弊
- nyoj 811 变态最大值
- C++中智能指针的设计和使用
- 笨方法学习C中文
- 基于HTML5实现的Heatmap热图3D应用
- 指针数组的初始化之返回第n个月份的名字(内部static数组的一种应用)续篇
- poj 1144 Network (割点)
- 常用的开源网站框架