leetcode19Remove Nth Node From End of List
来源:互联网 发布:修改软件下载 编辑:程序博客网 时间:2024/05/23 16:24
leetcode19Remove Nth Node From End of List
思路:
class Solution {public: ListNode* removeNthFromEnd(ListNode* head, int n) { int length = 0; ListNode *h1 = head; ListNode *tempHead = new ListNode(0); while(h1!=NULL) {length++;h1 = h1->next;} int nthFromStart = length - n + 1; tempHead->next = head; head = tempHead; h1 = head; while(nthFromStart-->1) h1 = h1->next; h1->next = h1->next->next; head = head->next; return head; }};
阅读全文
0 0
- leetcode19Remove 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
- [Java读书笔记]之Swing
- [学习笔记] 树状数组区间加+区间求和
- 整数全排列问题
- 不同的路径
- 给定一个链表,一次颠倒链表k的节点并返回其修改列表。如果节点的数量不是k的倍数,那末最后的剩余节点应该保持原样。
- leetcode19Remove Nth Node From End of List
- Java 8 – 怎样对Map排序
- BP算法
- AD的多根走线
- C++笔记(第四章)
- Jam的计数法
- 数据结构--向量
- kindeditor用法简介
- python 基础知识-----print多次输入不换行