19. Remove Nth Node From End of List
来源:互联网 发布:淘宝北京新大陆可靠吗 编辑:程序博客网 时间:2024/06/11 16:59
/** * 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 == NULL || head->next == NULL) return NULL; ListNode * first = head; ListNode * second = head; for(int i = 0;i < n;i++) first = first->next; if(first == NULL) return head->next; while(first->next != NULL) { first = first->next; second = second->next; } second->next = second->next->next; return head; }};
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
- CDH5.7/5.8离线安装-使用CM5,基于CentOS 6.7
- 博客搬迁
- Linux命令-find
- 机器学习经典图
- 【poj 3150】Cellular Automaton 矩阵
- 19. Remove Nth Node From End of List
- 沉浸式状态栏
- LambdaMART的源码分析:一(MART:回归树)
- 160601iOS 模拟器 打开关闭模拟键盘
- 微软研究院Detour开发包之API拦截技术
- c++-引用一维数组
- 我的女助理辞职了!---精英会里老板们不断转发的文章
- 6-6 8255并行接口(LED)
- [LeetCode][3]Longest Substring Without Repeating Characters解析 -Java实现