LeetCode 19. Remove Nth Node From End of List
来源:互联网 发布:软件及信息服务业 编辑:程序博客网 时间:2024/05/22 20:19
Given a linked list, remove the nth node from the end of list and return its head.
For example,
Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked list becomes 1->2->3->5.
Note:
Given n will always be valid.
class Solution {public: ListNode* removeNthFromEnd(ListNode* head, int n) { ListNode * pre, * now, * post; now = head; pre = now; post = now; for(int i = 1; i <= n; i ++){ post = post->next; } while(post != NULL){ pre = now; now = now->next; post = post->next; } if(pre == now){ head = head->next; return head; } pre->next = now->next; return head; }};
0 0
- 19. Remove Nth Node From End of List leetcode list
- [LeetCode]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 Leetcode Python
- 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 OJ> 19. Remove Nth Node From End of List
- 19. Remove Nth Node From End of List LeetCode
- leetcode 19. Remove Nth Node From End of List
- [LeetCode OJ] 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(JAVA)
- 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#员工排名系统之总结
- weak assign copy block
- jQuery选择器 过滤选择器(一.基本过滤选择器)
- python3 在django 中使用mysql报错 ImportError: No module named 'MySQLdb'
- 线程池技术
- LeetCode 19. Remove Nth Node From End of List
- JavaScript 开发进阶:理解 JavaScript 作用域和作用域链
- java过滤器实现Gzip压缩实例源码教程
- Ubuntu win7双系统后遇到的问题。时间和引导顺序
- nginx源码学习 主要的工作流程
- 方法与函数在概念上的区别
- Ubuntu16或者Ubuntu14 配置NVIDIA、CUDA以及CUDNN
- maven第一坑
- 添加手机顶部状态栏TitleBar,根据不同手机计算相应高度