Remove Nth Node From End of List
来源:互联网 发布:suse linux dns配置 编辑:程序博客网 时间:2024/05/16 07:34
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode *removeNthFromEnd(ListNode *head, int n) { if(!head) return 0; ListNode dummy(-1); dummy.next=head; ListNode *pEarly=&dummy; for(int i=0;i!=n;i++) { pEarly=pEarly->next; } ListNode *pLate=&dummy; while(pEarly->next) { pEarly=pEarly->next; pLate=pLate->next; } pLate->next=pLate->next->next; return dummy.next; }};
0 0
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node from End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- 调用模板类出现 undefined reference 错误的解决方法
- 内核线程的实例与摧毁
- linux中怎样从底部向上查看log文件
- ZOJ 1204 Additive equations
- TOJ 2429 Find the Clones
- Remove Nth Node From End of List
- Server2008R2:由于没有远程桌面授权服务器可以提供许可证,远程会话被中断..错误的解决方法
- SQL语句优化--1
- 打印内存地址
- 分割字符串数组
- Eclipse的使用技巧之如何出现全部提示字符
- (standard c libraries translation )fileno
- Extjs表单验证小结
- libevent源码分析--libevent库对信号事件的处理