19. Remove Nth Node From End of List
2016-03-19 21:25
459 查看
ListNode* removeNthFromEnd(ListNode* head, int n) { ListNode* first = head; ListNode* second = head; int i = 0; while (second) { i++; second = second->next; } int j= 0; if(i==n) return head->next; while (j < i-n -1) { first = first->next; j++; } first->next = first->next->next; return head; }
相关文章推荐
- nodejs learn
- node源码详解(四) —— js代码如何调用C++的函数
- 基于angular的route实现单页面cnodejs
- nodepad++搭建各种开发环境
- HDFS源码分析心跳汇报之DataNode注册
- nodepad++搭建各种开发环境
- 19. Remove Nth Node From End of List
- 安装ionic出现node-sass无法下载的解决方法
- nodeJS搭建本地服务器
- util
- HDU 4587 TWO NODES(割点,连通块,枚举)
- Node.js自定义对象事件监听与发射
- Hadoop启动没有namenode进程
- nodepad++搭建各种开发环境
- Node.js爬虫--网页请求模块
- 237. Delete Node in a Linked List
- 237. Delete Node in a Linked List
- 24. Swap Nodes in Pairs
- ext2文件系统源代码之inode.c
- nodejs: mkdirs 递归创建目录